I assume u use the default loggerRepositorySelector, which returns a Repository 
called Hierarchy. The call getCurrentLoggers() (doesnt matter if you called it 
on LogManager or on the LogManager.getLoggerRepository(), that's the same, see 
implementation of LogManager) returns only these Loggers which have been 
fetched before by a call to <instance of hierarchy>.getLogger( 'xy' ), again it 
does not matter on which way/path this method is called ( Logger.getLogger(), 
or LogManager.getLogger() ).

If you call 
  Logger myLog = Logger.getLogger( 'test');
then a subsequent call to 
  Enumeration en = Logger.getCurrentLoggers() 
then en should contain at least the instance myLog.

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]

Reply via email to