Logging is a useful and essential part of any application, therefore to get the most benefit from it, it is useful if MicroLite can utilise the same logging framework as your application.
For that reason, MicroLite does not include a specific logging framework, but rather allows any other framework to be used.
This is done by using extension packages, at present there are extension packages for log4net and NLog which are probably the most popular logging frameworks for .net.
Firstly, install the package you need
Install-Package MicroLite.Extensions.Log4Net or
The extension packages assume that the relevant setup and configuration of the logging framework has been done by the application using it.
Once the package is installed, you simply need to configure the extension:
// Load the extensions Configure .Extensions() .WithLog4Net(); // or .WithNLog(); // Create the session factory... Configure .Fluently() ...
It is recommended that the logging framework is the first extension loaded so that other extensions may also write to the log.
MicroLite will then write to the same log as your application.
This article was written for version 1.2.2 of the MicroLite framework.