Using Log4net in your web apps

by Steven Ng on March 20, 2007

Log4net is part of the Apache Logging Services Project. It’s a tool to help ASP.net developers log message to a text file, xml file, email or database.

  1. Add log4net.Config.XmlConfigurator.Configure(); to Global.asax in the Application_Start method.
  2. In your code-behind or BasePage.cs, declare protected static readonly ILog logger =
    log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  3. Web.config has all the magic. , , and

To be continued…

One comment

Very helpful.

by Scott on July 18, 2007 at 6:22 pm. #

Leave your comment

Required.

Required. Not published.

If you have one.