You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by pwomack <pw...@papermule.co.uk> on 2004/11/05 13:49:59 UTC

finding all log files for viewing?

We would like (in a GUI) to allow our
users to view any-and-all log files.

Is there a convenient way to locate all
active FileAppenders (and its sub-classes)?

The best I've come up with is to do is something like...

Set allFileAppenders = new HashSet();

LoggerRespository repos = Logger.getRootLogger().getLoggerRepository();
for(Enumeration le = repos.getCurrentLoggers(); le.hasMoreElements();) {
     Logger l = (Logger)le.nextElement();
     for(Enumeration ae = l.getAllAppenders(); ae.hasMoreElements();) {
         Appender a = (Appender)ae.nextElement();
         if(a instanceof FileAppender) {
             allFileAppenders.add(a);
         }
     }
}

I can then call getFile() on eaach FileAppender. Job Done.

(with apologies for dumb-ass typos)

Is there a better way?

     BugBear

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org