logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Elmhorst" <nos...@elmhorst.com>
Subject RE: Log4Net API to get appender config properties
Date Sat, 04 Dec 2004 00:56:12 GMT
Sure, here's a quick code snippet . . 


This will get you the appenders that have been appended to the root of the


IAppender fileApp = null;

IAppender consoleApp = null;

log4net.Repository.Hierarchy.Hierarchy hierarchy =
LogManager.GetLoggerRepository() as log4net.Repository.Hierarchy.Hierarchy;

foreach( IAppender app in hierarchy.Root.Appenders )


            if (app is ConsoleAppender)

                        consoleApp = app;

            else if (app is RollingFileAppender)


                        fileApp = app;

                        //Update the appender's schedule

                        RollingFileAppender ap = ( RollingFileAppender )app;

                        ap.DatePattern = sCfg.LogFileRollSchedule ;





From: Dan Johnston [mailto:dan_johnston@symantec.com] 
Sent: Friday, December 03, 2004 6:46 PM
To: log4net-user@logging.apache.org
Subject: Log4Net API to get appender config properties


Is it possible to access  appender properties via the log4Net API.  For
instance, I am interested in discovering the name of a rollingfileAppender
logfile name and path, but because it is dynamically created with respect to
time, parsing the log4net config file proves futile. 

It would appear that I should gain access to the Appenders Collection
object, but am uncertain as to how I go about doing this.  Any help on this
subject would be greatly appreciated. 


View raw message