Published on:Apr 26, 2010
Views: 9305
Number of votes: 0
Average rating:

log4net Tips: Do not declare a logger in Global.asax.cs

If you declare your own logger in Global.asax.cs (for the Global class) you will effectively turn off all log4net logging for the entire site.

Like this:

using log4net;
using System.Reflection;
public class Global : EPiServer.Global
// Very bad idea
static readonly ILog _log = log4net.LogManager.GetLogger(

Seems like not everyone knows about this – so consider yourself warned!

Apr 26, 2010

( 9/21/2010 10:33:18 AM)

So if we shouldn't declare a log4net logger here, is it possible to still use log4net in global.asax? I'd like to log un-handled exceptions from this class.
/ Striker

Please login to comment.