If you want to keep the db appender separate from the config file then you will need to create and attach the db appenders programmatically.
If by "but I want to carry over the category/log level nodes" you just mean the logger and levels then that should be fine they won't be effected by you adding your own appenders. If you mean that the config file should allow you to specify which appender is attached to which logger, including your db appenders then I think that you need to use a forwarding appender as a placeholder in the logger hierarchy. Then find the placeholder appender using the ILoggerRepository.GetAppenders method and attach your db appender to the forwarding appender. Cheers, Nicko > -----Original Message----- > From: Dag Christensen [mailto:[EMAIL PROTECTED] > Sent: 18 May 2006 09:47 > To: Log4NET User > Subject: Enabling an appender at run time > > > In my library's log4net setup I have two RollingFileAppenders > enabled by default. If the user logs on to a database > (depends on the application), I want to enable additional > AdoNetAppenders with connectionstrings pointing to the > database the user is logged on to (multiple choices). > > I believe I have three options (?) > > 1. Use a XML file for my RollingFileAppenders, dynamically > adding AdoNetAppenders at runtime (if possible, what happens > if the XML file > changes?) > 2. Add placeholder AdoNetAppenders to my XML file with > threshold = off and an empty connection string, and set these > at runtime? (again, the XML file can change). > 3. If I understand repositories correctly, is the suggested > solution to add a new repository? If so, can I copy my > category filters (level per > category) to the new repository? > > I believe I can use the > log4net.LogManager.GetRepository().ConfigurationChanged event > to detect changes to the XML file, but at this point I've > already lost my current settings? > > I'm a bit unsure how to solve this, preferably (I think..) > the database loggers should be kept separate from my XML > file, but I want to carry over the category/log level nodes. > > Hope this description was clear enough :-p Any suggestions > how to proceed to solve this ? > > > Thanks, > > Dag Christensen > Vestfold Butikkdata AS > ########################################### > > This message has been scanned by F-Secure Anti-Virus for > Microsoft Exchange. > For more information, connect to http://www.f-secure.com/ > >
