logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Location of log files
Date Tue, 05 Aug 2003 17:54:18 GMT

This is a common problem, and you have several options.

>The logging works fine. The problem is specifying the location of the
>I use log4j.xml to configure log4j. In there I have to specify the
>of the
>log file as absolute path. This creates a problem because we have to

You don't have to specify the path as absolute: it can be relative (to
the working directory), and it can contain environment variables.

>during each deployment of our application to edit the location of the

Another option is to automate this by copying the log4j.xml file with
filtering="true" in Ant.  In log4j.xml you'd have a token value for the
log file path, e.g. @logFilePath@, and when deploying you'd have Ant
replace this value with a value coming from an Ant property.

>I attempted to solve the problem by adding the following code in a
>		rootLogger = Logger.getRootLogger();
>		FileAppender fp = (FileAppender)

This is yet another option, the pure programmatic way.  I find this
useful some time, but cleaner if you create the appender
programmatically as well, i.e. 
Layout l = ...
String logFilePath = ....
Appender app = new FileAppder(l, logFilePath);

Yoav Shapira

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org

View raw message