Steve Celius
Apr 26, 2010
  10219
(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
Opticon 2024 - highlights

I went to Opticon in Stockholm and here are my brief highlights based on the demos, presentations and roadmaps  Optimizely CMS SaaS will start to...

Daniel Ovaska | Sep 27, 2024

Required fields support in Optimizely Graph

It's been possible to have "required" properties (value must be entered) in the CMS for a long time. The required metadata haven't been reflected i...

Jonas Bergqvist | Sep 25, 2024

How to write a bespoke notification management system

Websites can be the perfect vehicle for notifying customers of important information quickly, whether it’s the latest offer, an operational message...

Nicole Drath | Sep 25, 2024

Optimizely DAM – An Introduction

I presented a talk about the Optimizely DAM at the OMVP summit during Opticon 2024 in Sweden. I have now converted that talk into two blog posts....

Andrew Markham | Sep 25, 2024 | Syndicated blog

Simple and Effective Personalization with Optimizely Data Platform (ODP)

As we dive into the amazing capabilities of Optimizely One, let’s shine a spotlight on the Optimizely Data Platform (ODP). This simple tool unifies...

Alex Harris - Perficient | Sep 24, 2024 | Syndicated blog

SaaS CMS - Self-hosting Presentation Layer with Coolify

Introduction In my previous post, I explored the hosting options for the Hybrid Headless/Fully Headless presentation layer (frontend) using Netlify...

Minesh Shah (Netcel) | Sep 23, 2024