Try calling ActivateOptions on the appender so it knows its configuration has 
changed.

----- Original Message ----
From: Satish Musunuru <[EMAIL PROTECTED]>
To: [email protected]
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






Reply via email to