Thanks a lot!!!
-----Mensaje original-----
De: David Killeffer [mailto:[EMAIL PROTECTED]
Enviado el: Jueves, 03 de Enero de 2008 04:11 p.m.
Para: Log4J Users List
Asunto: Re: Is there a way to get all configured loggers?
Hi Nestor -
I had to do something similar for a servlet I was writing recently - as
part of the servlet, I declare a logger which is then used to get all the
loggers that have been configured, and then show which appenders are
attached to which loggers. The main function which I used to get all the
configured loggers and their appenders is like this:
private void showLoggers(Logger mainLogger, PrintWriter out) {
// get all the loggers
Enumeration allLoggers = mainLogger.getLoggerRepository
().getRootLogger().getLoggerRepository().getCurrentLoggers();
while (allLoggers.hasMoreElements()){
Logger logger = (Logger)allLoggers.nextElement();
// only show loggers that have appenders attached to them
try {
if ( logger.getAllAppenders().hasMoreElements() ) {
printLoggingSummary(logger, out);
}
} catch (Exception e) {
System.out.println("in showLoggerst().... " +
e.getStackTrace() + "\nMessage: " + e.getMessage() );
}
}
}
Hopefully this helps steer you in the right direction.
~ David
On Dec 31, 2007 3:25 PM, Néstor Boscán <[EMAIL PROTECTED]> wrote:
> Hi
>
> Is there a way to get a list of all configured loggers?
>
> Regards,
>
> Néstor Boscán
>
--
Best Regards,
David Killeffer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]