logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brendan Long" <Brendan.L...@yellowpages.co.nz>
Subject Programmatic configuration
Date Thu, 14 Sep 2006 02:10:41 GMT
Hi,
 
I am using log4net in a C# console application.  The requirements
specify that I retrieve the error log file and debug log file from the
registry.  Once I have done that I then need to configure my application
to log to those files (for all classes).
 
How do I do this?  I can't find a configuration example for programmatic
configuration, but it is mentioned in the documentation and examples as
being possible.  So far I have the following code.  It seems to create
the files, but nothing is ever logged to them.
 
   log4net.Appender.FileAppender fileAppenderTrace = new
log4net.Appender.FileAppender();
   log4net.Appender.FileAppender fileAppenderError = new
log4net.Appender.FileAppender();
   fileAppenderTrace.File = registry.getTracePath();  // Load debug log
file from registry
   fileAppenderError.File = registry.getLogPath();    // Load main/error
log file from registry
   log4net.Filter.LevelMatchFilter logFilter = new
log4net.Filter.LevelMatchFilter();
   logFilter.LevelToMatch = log4net.Core.Level.Info;
   log4net.Filter.LevelMatchFilter traceFilter = new
log4net.Filter.LevelMatchFilter();
   traceFilter.LevelToMatch = log4net.Core.Level.All;
   fileAppenderTrace.ClearFilters();
   fileAppenderTrace.AddFilter(traceFilter);
   fileAppenderError.ClearFilters();
   fileAppenderError.AddFilter(logFilter);

How can I complete the configuration?

Thanks,
Brendan.

This communication, including any attachments, is confidential. If you are not the intended
recipient, you should not read it - please contact me immediately, destroy it, and do not
copy or use any part of this communication or disclose anything about it. Thank you. Please
note that this communication does not designate an information system for the purposes of
the Electronic Transactions Act 2002.


Mime
View raw message