logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Sturm <oli...@sturmnet.org>
Subject Finding out whether a specific appender is attached
Date Wed, 08 Dec 2004 11:37:35 GMT
Hey,

I have an application that uses another assembly, written earlier, where 
a System.Diagnostics was used for debugging output. As the new 
application is supposed to use log4net for logging, I want to route that 
old Diagnostics stuff into log4net and I have successfully created my 
own derived TraceListener that does that for me.

Now, on my development system, I like to set up log4net to use a 
TraceAppender so that I can easily see the log4net output in Visual 
Studio when debugging. Of course, I can't use my own TraceListener and 
the log4net TraceAppender at the same time. So I'd like to find out 
(during initialization of my app) whether a TraceAppender is in the root 
category of the current log4net configuration and only set up my 
TraceListener if there's no TraceAppender.

I have had close looks around the SDK help file and I tried a lot 
myself, but I can't figure out where to get access to the appenders that 
are configured for the root category.

In theory, it seems to be possible to query the appenders for a specific 
logger, but then (1) I don't know which one to use at that early point 
of the application initialization and (2) using only the interfaces that 
I can usually get to, this would at least involve a lot of assumptions 
(and casts).

I've also written some code that uses GetCurrentLoggers and iterates 
over the loggers it gets and in the debugger it looked like the 
Appenders property deep down in the class that's returned for each 
logger doesn't even contain any appenders at this point.

So, to restate the question very simply: How can I find out 
programatically which appender types are configured for the root category?

Thanks!

               Oliver Sturm
-- 
omnibus ex nihilo ducendis sufficit unum
MSN oliver@sturmnet.org Jabber sturm@amessage.de ICQ 27142619


Mime
View raw message