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 Richard Louapre <Ri...@nyc.hummingbird.com> on 2005/04/01 18:38:10 UTC

RE: Programmatically update the config file.

I did some quick tests and seems to be possible using reflection to generate
an XmlDocument.

I have just one issue, because a lot of Properties should not be store in
the XmlDocument (for example for any Appender : name, encoding,
errorhandler, securitycontext, ...) Would it possible in the next version of
log4net to implement a custom attribute to mark the Properties that are
"exportable" or not?

That will save a lot of if statement in order to skip these properties.

Is there a DTD available to validate the log4net.config?

Ciao,
	Richard.

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Thursday, March 31, 2005 12:18 PM
To: Log4NET User
Subject: RE: Programmatically update the config file.


I would look at the source code to see how log4net reads and processes its
config file. I think I saw an overload for Configure(XmlElement). 

 DOMConfigurator
--- Richard Louapre <Ri...@nyc.hummingbird.com> wrote:
> Thanks for your answer.
> 
> <log4net>
> 	<appender name="Console" type="log4net.Appender.ConsoleAppender">
> 		<layout type="log4net.Layout.PatternLayout">
> 			<!-- Pattern to output the caller's file name and
> line number -->
> 			<conversionPattern value="%5level [%thread]
> (%file:%line) - %message %newline" />
> 		</layout>
> 	</appender>
> 	<root>
> 		<level value="DEBUG"/>
> 		<appender-ref ref="Console" />
> 	</root>
> </log4net>
> 
> So if I understand correctly, I will need to generate "manually" an 
> XmlDocument for this log4net settings above. There is no way to 
> serialize the Hierarchy object and get in output this XmlDocument?
> If there is no way, is there an exact matching between the property
> name and
> associated node in the config file? That could help me a lot using
> Reflection.
> 
> Thanks again.
> 
> Ciao,
> 	Richard.
> 
> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com]
> Sent: Thursday, March 31, 2005 11:50 AM
> To: Log4NET User
> Subject: Re: Programmatically update the config file.
> 
> 
> The config file is just a standard XML file. Have you tried using an 
> XmlDocument object to read the file in, make your changes, then write 
> it back to the file system? If you've configured log4net to place a 
> file system
> watch on the file, when you save the file back out to the hard drive
> log4net
> will re-process it and the changes will take affect.
> 
> 
> - Ron
> 
> --- Richard Louapre <Ri...@nyc.hummingbird.com> wrote:
> > Hi,
> > 
> > I need to programmatically update the config file (log4net.config)
> in
> > order to keep the changes apply to my log system.
> > I did not find anything to do that, maybe I have missed something.
> > 
> > Does anybody have an sample?
> > 
> > Many Thanks.
> > 
> > Ciao,
> > 	Richard.
> > 
>