You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by rodchar <ro...@hotmail.com> on 2009/02/18 16:40:33 UTC
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 get
the logger down into the business and data layers?
thanks,
rodchar
--
View this message in context: http://www.nabble.com/multi-tier-app-and-log4net-tp22081382p22081382.html
Sent from the Log4net - Dev mailing list archive at Nabble.com.
RE: multi-tier app and log4net
Posted by "Walden H. Leverich" <Wa...@TechSoftInc.com>.
> 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");
log4net.Config.XmlConfigurator.ConfigureAndWatch(new
System.IO.FileInfo(configFile));
log = log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType
);
log.Info("----------------------");
log.Info("Application Starting... Good morning.");
log.InfoFormat("Watching '{0}'", configFile);
log.Info("Application Active.");
log.Info("--");
#endregion
}
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
=log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType
);
#endregion
And it all works fine.
-Walden
--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@TechSoftInc.com
http://www.TechSoftInc.com
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 <ro...@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
get
the logger down into the business and data layers?
thanks,
rodchar
--
View this message in context:
http://www.nabble.com/multi-tier-app-and-log4net-tp22081382p22081382.htm
l
Sent from the Log4net - Dev mailing list archive at Nabble.com.
Re: multi-tier app and log4net
Posted by Ron Grabowski <ro...@yahoo.com>.
Have you tried to configure log4net once at the highest level when the application starts?
----- Original Message ----
From: rodchar <ro...@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 get
the logger down into the business and data layers?
thanks,
rodchar
--
View this message in context: http://www.nabble.com/multi-tier-app-and-log4net-tp22081382p22081382.html
Sent from the Log4net - Dev mailing list archive at Nabble.com.
Re: multi-tier app and log4net
Posted by rodchar <ro...@hotmail.com>.
thanks for the help,
rod.
rodchar wrote:
>
> 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
> get the logger down into the business and data layers?
>
> thanks,
> rodchar
>
--
View this message in context: http://www.nabble.com/multi-tier-app-and-log4net-tp22081382p22120452.html
Sent from the Log4net - Dev mailing list archive at Nabble.com.