Introducing Caliburn.Micro.Logging.NLog

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.NLog 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.NLog

Using NuGet for Caliburn.Micro.Logging.NLog

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

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

Getting the Code for Caliburn.Micro.Logging

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.NLog

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.

static AppBootstrapper()
{
  LogManager.GetLog = type => new NLogLogger(type);
}

That is the only change to complete integration, but NLog has a lot of configuration options. Check out my earlier post How To Do Logging with Caliburn.Micro to see a few examples, but for richer configuration examples I suggest checking out the NLog Configuration Wiki.

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.

Related

comments powered by Disqus