Register / Login
Other Open Source Projects
Log4j: How to retrieve RollingFileAppender's file name and path?
posted 8 years ago
Can anyone tell me how I can retrieve the file name and path of my Log4j log file from within my
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.
I'm sure it ought to be pretty simple so many thinaks if you can offier me the answer.
posted 7 years ago
I did work out my own answer to this one, so for anyone else who might need it:
RollingFileAppender x = (RollingFileAppender) Logger.getRootLogger().getAppender("R"); logger.debug("Logging to: " + x.getFile());
This would output:
"Logging to: \blah\xxx.log"
I've used this successfully in
can I set the path in my code to refer a properties file?
location of log file when using log4j
problem of log4j in tomcat 4.1.27
log4j refuses to write to file
log4j file logging problem