logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Getting Appenders At Runtime
Date Sun, 14 Aug 2005 22:44:27 GMT
log4net 1.2.9 has a method to get all the currently configured appender:

log4net.LogManager.GetRepository().GetAppenders()


If you are using 1.2.0-Beta8 you need to do this manually.
Actually you are very close, the only problem with your code is that the
<root> logger is not called "root", in fact it cannot be looked up by
name.

The way to get the <root> logger is:

((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Roo
t

Then use the GetAppender method to retrieve your appender.

Cheers,
Nicko

> -----Original Message-----
> From: Dean Fiala [mailto:dfiala@celadonlabs.com] 
> Sent: 09 August 2005 19:11
> To: log4net-user@logging.apache.org
> Subject: Getting Appenders At Runtime
> 
> How do you get the active appenders at runtime?  I apologize 
> for a basic question, but an hour of googling and manual 
> reading have led to nada.
> 
> I'm working in 1.2.0-Beta8.
> 
> I'm doing a DOM configuration with a simple rolling file 
> appender set at root, named "RollingFile". I am able to 
> successfully log. However, I cannot figure out how to grab a 
> reference to the appender, which would be useful for debugging.
> 
> I've done this:
>  Dim log As ILog = LogManager.GetLogger("root")  Dim 
> connectionAppender As IAppenderAttachable = log.Logger  Dim 
> app As RollingFileAppender =
> connectionAppender.GetAppender("RollingFile")
> 
> But app always = nothing, and the 
> connectionAppender.Appenders collection is always empty.
> 
> Any clues, hints, or suggestions would greatly appreciated.
> 
> 
> 
> 
> 

Mime
View raw message