Configuring log4net appenders via XML file *and* code
Posted
by Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2010-05-11T00:26:08Z
Indexed on
2010/05/11
0:34 UTC
Read the original article
Hit count: 375
I started to play with log4net today and so far, I really like it. In order to preserve our current logging functionality, the app needs to create a new log file whenever the application is started. The log file name has the date and time stamp encoded in it. Currently, I've got log4net configured via an XmlConfigurator
, which works great, except that the filename for my RollingFileAppender
is hardcoded in the configuration XML file.
I'd like to continue to use the XmlConfigurator
, but after calling Configure()
, I want to get at the RollingFileAppender
and, in code, change its file value to be a dynamically-generated string. The sample documentation online seems to be down right now, but I've poked through the SDK reference, and it looks like I could use the Heirarchy
and GetAppenders()
to do what I need to do. Am I on the right track?
© Stack Overflow or respective owner