File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Log4j: How to retrieve RollingFileAppender's file name and path? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j: How to retrieve RollingFileAppender Watch "Log4j: How to retrieve RollingFileAppender New topic
Author

Log4j: How to retrieve RollingFileAppender's file name and path?

Guy Home
Greenhorn

Joined: Aug 23, 2008
Posts: 2
Hi,

Can anyone tell me how I can retrieve the file name and path of my Log4j log file from within my java application code?

i.e how can I get my app to return log4j.appender.R.File below as held in my log4j.properties?


# ***** R is set to be a RollingFileAppender.
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/blah/xxx.log


I'm sure it ought to be pretty simple so many thinaks if you can offier me the answer.
Guy Home
Greenhorn

Joined: Aug 23, 2008
Posts: 2
I did work out my own answer to this one, so for anyone else who might need it:



This would output:
"Logging to: \blah\xxx.log"

I've used this successfully in http://gmdx.net/log4j/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j: How to retrieve RollingFileAppender's file name and path?
 
Similar Threads
log4j refuses to write to file
can I set the path in my code to refer a properties file?
problem of log4j in tomcat 4.1.27
location of log file when using log4j
log4j file logging problem