From what you describe, it sounds like you have all the ingredients
already in place. :-)
Modify your existing servlet to configure log4j as follows:
Properties props = new Properties();
// add the REL_PATH property with value of relative path
props.put("REL_PATH", this.getRelativePath());
// merge props with log4j.properties
props.load("log4j.properties");
PropertyConfigurator.configure(props);
In your log4j.properties file use log4j's parameter substitution
facility:
log4j.rootLogger=DEBUG, MY_LOG
...
log4j.appender.MY_LOG=org.apache.log4j.FileAppender
log4j.appender.MY_LOG.file=${REL_PATH}/mylog.txt
...
I hope this helps but at least should point you at the right direction.
At 04:45 PM 8/23/2005, you wrote:
Hello,
I've spent several hours trying to figure this out with no luck. I need
to be able read a log file for a web application. I don't have access to
the files in production so I've written a servlet that allows me to set
logging levels as well as read the log file. The problem is I need to
use a relative path which doesn't seem to be possible in log4j. I can't
use environment an variable. This seems to be a solution offered by
others. I did come across one suggestion to use the getRelativePath()
but I don't know how to set this in the log4j.properties file.
Is there a solution for this or even an alternative to log4j if this is
not possible?
Thanks,
-------------------------------------------------------
Richard C. Elsberry
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]