logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: Location of log files
Date Tue, 05 Aug 2003 17:56:32 GMT

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: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message