November Happy Hour will be moved to Thursday December 5th.

Steve Celius
Apr 26, 2010
  10270
(0 votes)

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!

Apr 26, 2010

Comments

Sep 21, 2010 10:33 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.
Latest blogs
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog