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(
MethodBase.GetCurrentMethod().DeclaringType);
...
}
Seems like not everyone knows about this – so consider yourself warned!
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