Have you tried using system properties? Log4j performs variable substitution in XML files as well.


At 01:44 PM 8/5/2003 -0400, Grum Ketema wrote:
Hello

I could not find a simple solution
to this problem. I deploy a web application (a War file) in
a web server (iplanet) and an ejb application ( an ear file) in
OAS (oracle application server). I want to use log4j in both applications.
The logging works fine. The problem is specifying the location of the log
file.
I use log4j.xml to configure log4j. In there I have to specify the location
of the
log file as absolute path. This creates a problem because we have to edit
log4j.xml
during each deployment of our application to edit the location of the log
file.
I attempted to solve the problem by adding the following code in a utility
class

rootLogger = Logger.getRootLogger();
FileAppender fp = (FileAppender) rootLogger.getAppender("LOGFILE");
String fileName = fp.getFile();
String dir = getOracleRootDir();
if (dir!=null) {
StringBuffer logFilePath = new StringBuffer(dir);


logFilePath.append(File.separator+"log"+File.separator+fileName);
                                fp.setFile(logFilePath.toString());
                                fp.activateOptions();
                }

which is kind of clumsy. Is there any way of specifying the location of the
log
file without editing log4j.xml (e.g. programmatically or otherwise)

Regards,
Grum

-- Ceki For log4j documentation consider "The complete log4j manual" ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to