Hi all,

I found this code in a stack overflow question/answer:

private static readonly ILog logger = 
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

PatternLayout layout = new PatternLayout(@"%date %-5level %message%newline");
   FileAppender appender = new FileAppender();
    RollingFileAppender appender = new RollingFileAppender();  // why same 
variable used for second "new" object?
    appender.Layout = layout;
    appender.File = "c:\log.txt";
    appender.AppendToFile = true;
    appender.MaximumFileSize = "1MB";
    appender.MaxSizeRollBackups = 0;
    appender.Threshold = Level.Error;
    appender.ActivateOptions();
    log4net.Config.BasicConfigurator.Configure(appender);

I am confused by the line I commented - why would anyone use the same variable 
twice as this code shows?  It would seem that the "FileAppender appender = new 
FileAppender();" line (above the commented line) is pointless, but maybe the 
code is not complete, or there is something about log4net that I'm not getting.

Here is the stack overflow link:

http://stackoverflow.com/questions/650694/changing-the-log-level-programmaticaly-in-log4net

Thanks in advance,
Peter


The information contained in this message may be privileged, confidential and 
protected from disclosure. If the reader of this message is not the intended 
recipient, or an employee or agent responsible for delivering this message to 
the intended recipient, you are hereby notified that any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this communication in error, please notify your representative 
immediately and delete this message from your computer. Thank you.

Reply via email to