logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walden H. Leverich" <Wald...@TechSoftInc.com>
Subject RE: multi-tier app and log4net
Date Thu, 19 Feb 2009 14:53:16 GMT
> is there a way to intantiate once and use thru out my tiers?

The logger is initialized once per app-domain, so as long as you do it
at the start of the app you're good. And what's the start of the app for
a web site? Global.asax. Here's what we do:

In Global.asax:

//Log4Net logger, can be initialized like normal since we need to
configure log4net first. That's done below.
static log4net.ILog log;

protected void Application_Start(object sender, EventArgs e)
	#region Bootstrap log4net
	string configFile = Server.MapPath("~/log4net.config");

	log = log4net.LogManager.GetLogger(

	log.Info("Application Starting... Good morning.");
	log.InfoFormat("Watching '{0}'", configFile);
	log.Info("Application Active.");
protected void Application_End(object sender, EventArgs e)
	log.Info("Application Ending... Goodnight.");

And is a normal file, either an aspx.cs, or a file just in a data-layer
DLL we simply do:

#region Log4Net
static readonly log4net.ILog log

And it all works fine.


Walden H Leverich III
Tech Software
(516) 627-3800 x3051

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Wednesday, February 18, 2009 11:13 PM
To: Log4NET Dev
Subject: Re: multi-tier app and log4net

Have you tried to configure log4net once at the highest level when the
application starts?

----- Original Message ----
From: rodchar <rodchar@hotmail.com>
To: log4net-dev@logging.apache.org
Sent: Wednesday, February 18, 2009 10:40:33 AM
Subject: multi-tier app and log4net

hey all,
i have a web app that is multi-tiered (ui,bll,dal). is there a way to
intantiate once and use thru out my tiers? if so, what's the best way to
the logger down into the business and data layers?

View this message in context:
Sent from the Log4net - Dev mailing list archive at Nabble.com.

View raw message