You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Dan Johnston <da...@symantec.com> on 2004/12/04 01:45:41 UTC

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.

Thanks,
dan

log4net Serialization

Posted by Dru Sellers <ds...@chinaleads.net>.
Is there anyway I can use log4net in an application that requires
serialization?
 
I have seen people with issues in the past, and I don't really want to
serialize the whole Object Graph but are there any good ideas out there?
 
Dru

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.805 / Virus Database: 547 - Release Date: 12/3/2004
 

RE: Log4Net API to get appender config properties

Posted by Andrew Elmhorst <no...@elmhorst.com>.
Sure, here's a quick code snippet . . 

 

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

 

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. 

Thanks, 
dan