logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Programmatically setting Header
Date Thu, 15 Nov 2007 03:38:24 GMT
Try calling ActivateOptions on the appender so it knows its configuration has changed.

----- Original Message ----
From: Satish Musunuru <Satish.Musunuru@codeobjects.com>
To: log4net-user@logging.apache.org
Sent: Wednesday, November 14, 2007 8:28:58 PM
Subject: Programmatically setting Header

Programmatically setting Header


 
 




Hi,


   I have all my log4net settings in a configuration file except for the header. This is because
I want to output the product version information at the beginning of each log file. This version
info is only available to me at runtime. How can I set the Header programmatically?


I tried the following but it doesn't work…



ILog iLog = LogManager.GetLogger(typeof(ICOLogger));


ILoggerRepository repository = iLog.Logger.Repository;


foreach (IAppender appender in ((log4net.Repository.Hierarchy.Hierarchy)repository).Root.Appenders)


{


        if (appender is RollingFileAppender)


        {


                PatternLayout patternLayout = (PatternLayout)((RollingFileAppender)appender).Layout;


                patternLayout.Header = "Version 1.1.2";


      }


}



Thanks,


Satish







Mime
View raw message