Hi Marco,
To make sure, you get all available loggers , I would use
for( Enumeration enumLoggers =
LogManager.getCurrentLoggers();enumLoggers.hasMoreElements();) {
Logger logCurrent = (Logger) enumLoggers.nextElement() ;
for (Enumeration enumAppenders =
logCurrent.getAllAppenders();enumAppenders.hasMoreElements();) {
.... evaluate your appender
}
}
However I would do it the other way around. Why don't you write your own Managing
class, and when an Appender is instantiated (or bound to a logger) register it with
this class? Then you could ask your own Manager class.
Regards
Gyoergy
-----Urspr�ngliche Nachricht-----
Von: Marco Herrn [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 5. M�rz 2004 11:00
An: [EMAIL PROTECTED]
Betreff: getting an Appender object at runtime
I have written my own Appender by extending AppenderSkeleton. Log4j uses
this Appender, so everything is fine.
But I need my application to access this Appender at runtime so that
they can register with this Appender to get the logging events forwarded
(the Appender has a method register() that is called by all classes that
want to get the LoggingEvents forwarded).
But now I have the problem accessing the Appender.
I tried it this way:
logger = Logger.getLogger(NetzAppManager.class);
logger.info("got the logger");
Enumeration e= logger.getAllAppenders();
The Problem is, I get a NullNumeration. The appenders obviously exist,
since the logger.info() statement works, I get append() events on all
appenders.
What have I done wrong?
Marco
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]