I'm using the LogInfo() method to log to a rolling flat file, but I need to change the conversion pattern or pattern layout (whatever you want to call it) temporarily when calling it in a certain circumstance. Is this possible?
A:
Yes it is, for instance like this:
var appenders = log4net.LogManager.GetRepository().GetAppenders();
foreach (var rollingFileAppender in appenders.OfType<log4net.Appender.RollingFileAppender>())
{
rollingFileAppender.Layout = new log4net.Layout.PatternLayout("- %message%newline");
}
Stefan Egli
2010-06-13 10:23:06