Introducing Caliburn.Micro.Logging.log4net

Categories: Programming
Comments: 2 Comments
Published on: July 6, 2011

Continuing my current mission to NuGet-ify my current utility libraries, and building on my Introducing Caliburn.Micro.Logging post, I have now released Caliburn.Micro.Logging.log4net which integrates log4net into Caliburn.Micro. There were no code changes to this from the code in my earlier post How To Do Logging with Caliburn.Micro, so it should be very easy to migrate to the NuGet package.

How to Use Caliburn.Micro.Logging.log4net

Using NuGet for Caliburn.Micro.Logging.log4net

The NuGet package id is Caliburn.Micro.Logging.log4net. So you can install the package from the NuGet package manager shell using the following command:

PM> Install-Package Caliburn.Micro.Logging.log4net

or if you are more GUI minded, use the Add Package Reference dialog.

Getting the Code for Caliburn.Micro.Logging.log4net

You can find the code for Caliburn.Micro.Logging on github at https://github.com/dbuksbaum/Caliburn.Micro.Logging.

Configuring Your Code to use Caliburn.Micro.Logging.log4net

Once you have added the Caliburn.Micro.Logging.log4net NuGet package to your project, just modify the bootstrapper by adding a static constructor that sets the GetLog delegate.

1 static AppBootstrapper() 2 { 3 LogManager.GetLog = type => new log4netLogger(type); 4 }

That is the only change to complete integration, but log4net still has some required configuration. Check out my earlier post How To Do Logging with Caliburn.Micro to see what you need to do if you are unfamiliar with log4net.

Summary

The small refactoring done in Caliburn.Micro.Logging has made the creation of this package trivial. I hope you find it as useful as I do.

In the meantime, if you have suggestions, comments, or critiques, please add a comment below, add an issue to the issue tracker, or send me email using the blog comment form.


Kick It on DotNetKicks.com
Share this
2 Comments - Leave a comment
  1. Apurva says:

    Hello,

    I am using your package to integrate log4net with Caliburn Micro in my WPF Application. I do have a few questions on using this package-

    1) So I assume that with this new package, I dont need to create Log4netLogger class as shown in your sample? Please correct me if I am wrong.

    2) How do I use this logger in my bootstrapper? I am trying to write unhandled exceptions to log in my bootstrapper.

    3) I noticed that this logging seems to work fine only on my machine. But when I deploy this application, I dont see any logs getting created. Is there any configuration step I should be taking care of?

    Appreciate your help!
    Apurva

  2. I think you’ve forgotten to make Caliburn.Micro.Logging.log4net declare it’s dependency on Caliburn.Micro.Logging in the package manifest.

Leave a comment

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Welcome , today is Wednesday, June 19, 2013
Statistical data collected by Statpress SEOlution (blogcraft).