logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vivek R. Rathod" <vrat...@appsecinc.com>
Subject RE: Using an Appender as a Template
Date Wed, 28 Jul 2010 17:58:03 GMT
I second this. If possible, I would like to do this as well
-Vivek
________________________________________
From: Matt Emory [repairman2003@gmail.com]
Sent: Wednesday, July 28, 2010 1:32 PM
To: log4net-user@logging.apache.org
Subject: Using an Appender as a Template

How can I add an appender in code but use options that I've defined in a config file?

Here's an example where I'm dynamically adding an appender.  But ultimately, I would like
to define these options in the config file and load those options into the appender I create
here:

 log4net.Repository.Hierarchy.Logger l = LogManager.GetLogger(projectName).Logger as log4net.Repository.Hierarchy.Logger

      log4net.Appender.RollingFileAppender appender = new log4net.Appender.RollingFileAppender();
      appender.AppendToFile = true;
      appender.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Size;
 appender.CountDirection = 1;
      appender.MaximumFileSize = "5000KB";
 …
 l.AddAppender(appender);


Mime
View raw message