Tuesday, May 6, 2008

Initialization code for log4net in c# web service project

log4net is the .NET version of the Java logger, log4j. I have used it in both .NET Full and .NET CF Framework projects. Now, I have developed a sample web service and successfully configured the application to use log4net. The one tricky part is to correctly tell the application to load the configuration settings when it starts.

The initialization code can be put in the the web project's Global.asax.cs:

The Application_Start method is called automatically when the web service is loaded, and thus, it is the ideal place to initialize the log4net environment.

More info on log4net

No comments: