How to include log4net in a dot net application
Log4net is a great logger for .net, sadly i can not understand the apache.org support docs. To make log4net work in dot net you can do the following:
Get log4net binaries from here e.g. log4net 1.2.10
Add reference to log4net.dll
Add this to your app.config document:
Sample app.config
Make sure you add this if its a standard .exe
XmlConfigurator.Configure();
Add this line to your class to get a logger object:
private static readonly ILog _log = LogManager.GetLogger(Assembly.GetEntryAssembly(), Assembly.GetEntryAssembly().GetType());
There are some other tricks to follow if you are loading a dll or being hosted by a process but have your own config doc. More to follow shortly.









No Comments, Comment or Ping
Reply to “How to include log4net in a dot net application”