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: Appenders current file path?
Date Sun, 14 Aug 2005 21:15:11 GMT
You can iterate through the appenders and locate your file appender (or
RollingFileAppender) like this:

foreach(log4net.Appender.IAppender appender in
log4net.LogManager.GetRepository().GetAppenders())
{
  if (appender is log4net.Appender.FileAppender)
  {
    log4net.Appender.FileAppender fileAppender =
(log4net.Appender.FileAppender)appender;

    // Get value of properties
    string filePath = fileAppender.File;
  }
} 

Cheers,
Nicko

> -----Original Message-----
> From: Russell Haley [mailto:rhaley@axys.com] 
> Sent: 06 August 2005 00:23
> To: Log4NET User
> Subject: Appenders current file path?
> 
> Is there a way of getting the current filename (preferably 
> the whole path) of a rolling file appender? I'm using a file 
> appender that rolls on date and creates specific paths for 
> each month and year and I'd like to have my application bring 
> up the current log file in notepad without having the user 
> look for it.
> 
> Cheers!
> Russ
> 
> 
> 

Mime
View raw message