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: Log4Net API to get appender config properties
Date Wed, 08 Dec 2004 13:23:57 GMT
You can get all the current appenders by using a method like:

public static log4net.Appender.IAppender[] GetAllAppenders()
{
  ArrayList appenders = new ArrayList();

  log4net.Repository.Hierarchy.Hierarchy h =
(log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetLoggerRepo
sitory();
  appenders.AddRange(h.Root.Appenders);

  foreach(log4net.Repository.Hierarchy.Logger logger in
h.GetCurrentLoggers())
  {
    appenders.AddRange(logger.Appenders);
  }

  return
(log4net.Appender.IAppender[])appenders.ToArray(typeof(log4net.Appender.
IAppender));
}

Nicko

> -----Original Message-----
> From: Dan Johnston [mailto:dan_johnston@symantec.com] 
> Sent: 04 December 2004 00:46
> To: log4net-user@logging.apache.org
> Subject: Log4Net API to get appender config properties
> 
> 
> Is it possible to access  appender properties via the log4Net 
> API.  For instance, I am interested in discovering the name 
> of a rollingfileAppender logfile name and path, but because 
> it is dynamically created with respect to time, parsing the 
> log4net config file proves futile. 
> 
> It would appear that I should gain access to the Appenders 
> Collection object, but am uncertain as to how I go about 
> doing this.  Any help on this subject would be greatly appreciated. 
> 
> Thanks,
> dan
> 

Mime
View raw message