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 18:42:27 GMT
Yes, but this requires you to have a live logger defined in the config file as  opposed to
just having an Appender defined. And, in case you are working with the  RollingFileAppender,
when log4net loads the logger, it will touch the file you specify, which you may not want.
-Vivek
________________________________________
From: Rob Richardson [Rob.Richardson@rad-con.com]
Sent: Wednesday, July 28, 2010 2:08 PM
To: Log4NET User
Subject: RE: Using an Appender as a Template

Couldn't you have a sample logger defined in your config file, open that
in code, and then copy its settings into your dynamically created
appender?

log4net.Repository.Hierarchy.Logger l =
LogManager.GetLogger(projectName).Logger as
log4net.Repository.Hierarchy.Logger
log4net.Appender.RollingFileAppender appender = new
log4net.Appender.RollingFileAppender();

Log4net.Repository.Hierarchy.Logger sample =
LogManager.GetLogger("SampleLog");
appender.AppendToFile = sample.Appender["SampleAppender"].AppendToFile;

RobR, probably showing his ignorance

Mime
View raw message