As far as I can tell, it returns the name of the file in the configuration. If you are using a RollingFileAppender, and you want access to a file that has been closed (e.g., myFile.txt.1) you'll
have to append that suffix yourself.


If you are using the DailyRollingFileAppender you should be able to figure out the suffix based on the DatePattern you have set.

http://logging.apache.org/log4j/docs/api/org/apache/log4j/FileAppender.html

This should help.

Marc Esher (4-2060) wrote:

Thanks Matt.

Before I try this out myself, which will be in the next couple of hours:
will this return the value of "File" as set in the properties, or will
it return the current file being logged to (i.e. myFile.txt.1)?


-----Original Message-----
From: Matt Hughes [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 27, 2004 2:37 PM
To: Log4J Users List
Subject: Re: getting file path for a logger


Marc Esher (4-2060) wrote:



Hi All,

Is there a way to have log4J return to me a string containing the


file


path for a specific logger?



Thanks.






It goes something like this.

Logger logger = LogManager.getLogger(Some.class);
Enumeration e = logger.getAllAppenders();
while (e.hasMoreElements()) {
   Appender a = (Appender)e.nextElement();
   if (a instanceof FileAppender) {
     FileAppender fa = (FileAppender)fa;
      //This
       String fileName = fa.getFile();
   }
}
}

---------------------------------------------------------------------
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