Right ... I'll delete my (unsent) reply... The getCurrentLoggers() call works. I got that far. But there are no attached appenders (that's the null enumeration), even though it's correctly writing to the file per the log4j.properties setup...
-----Burton -----Original Message----- From: Bender Heri [mailto:[EMAIL PROTECTED] Sent: Thursday, December 01, 2005 12:04 PM To: Log4J Users List Subject: RE: Silly ? - How do I figure out the name of the file the log is being written to? Forget my previous answer. The Loggers are already in repository after the default initialization. If the call Logger.getLogger( 'xy' ) returns a real logger, then also the call to LogManager.getCurrentLoggers() should return an enumeration which contains this same logger. Otherwise your default initialization failed. Heri > -----Original Message----- > From: Burton Strauss [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 01, 2005 6:33 PM > To: 'Log4J Users List' > Subject: RE: Silly ? - How do I figure out the name of the file the > log is being written to? > > > Changed > > Enumeration loggers = LogManager.getCurrentLoggers(); > > To: > > Enumeration loggers = > LogManager.getLoggerRepository().getCurrentLoggers(); > > > Same results (null enumeration) > > > -----Burton > > > -----Original Message----- > From: krishna kumar [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 01, 2005 10:27 AM > To: Log4J Users List > Subject: RE: Silly ? - How do I figure out the name of the file the > log is being written to? > > > > May be you can try with > > LogManager.getLoggerRepository().getCurrentLoggers() > in your code .. > > and let us know whether it works for u. > > Regards, > Krish > > --- Burton Strauss <[EMAIL PROTECTED]> > wrote: > > > My original test used getAllAppenders() to try and find > this, but it > > returned NullEnumeration. > > > > Logger logger = null; > > logger = logger.getLogger("test"); > > logger.info("Beginning logger walk"); > > > > int countOfLoggers = 0; > > Enumeration loggers = > > org.apache.log4j.LogManager.getCurrentLoggers(); > > if(loggers != null){ > > while(loggers.hasMoreElements()){ > > Logger l = (Logger)loggers.nextElement(); > > logger.info(l.getName()+" > > number:"+(++countOfLoggers)); > > int countOfAppenders = 0; > > Enumeration allAppenders = > > l.getAllAppenders(); > > System.out.println(allAppenders.getClass()); > > if(allAppenders !=null){ > > while(allAppenders.hasMoreElements()){ > > Appender a = > > (Appender)allAppenders.nextElement(); > > if(a instanceof FileAppender){ > > logger.info("FileAppender"); > > } > > countOfAppenders++; > > } > > } > > } > > } > > > > Gives: > > > > run-single: > > class org.apache.log4j.helpers.NullEnumeration > > > > > > With log4j.properties: > > > > log4j.rootLogger=debug,test > > > log4j.appender.test=org.apache.log4j.DailyRollingFileAppender > > log4j.appender.test.Append=false > > log4j.appender.test.File=testbed.log > > > log4j.appender.test.layout=org.apache.log4j.SimpleLayout > > > > > > > > -----Burton > > > > > > -----Original Message----- > > From: Bender Heri [mailto:[EMAIL PROTECTED] > > Sent: Thursday, December 01, 2005 3:14 AM > > To: Log4J Users List > > Subject: RE: Silly ? - How do I figure out the name of the file the > > log is being written to? > > > > (FileAppender) Logger.getLogger( <aLoggerName> ).getAppender( > > <aAppenderName> ).getFile(); > > > > > -----Original Message----- > > > From: Burton Strauss > > [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, December 01, 2005 5:10 AM > > > To: [email protected] > > > Subject: Silly ? - How do I figure out the name of > > the file the log is > > > being written to? > > > > > > > > > (For want of a better explanation, I want to use > > > system.out.println() to > > > tell the user where to look for the log file) > > > > > > The log4j logging works great, but I can't figure > > out how to grab the > > > file name so I can output it... > > > > > > > > > Thanks! > > > > > > -----Burton > > > > > > > > > > > > --------------------------------------------------------------------- > > > 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] > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com > > --------------------------------------------------------------------- > 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] > > --------------------------------------------------------------------- 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]
