You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Steve Cohen <SC...@sportvision.com> on 2003/02/20 00:19:57 UTC

controlling the location of log files

Is there a way, without writing system-dependent absolute paths in the
log4j configuration file to control where log4j puts the logs?  In other
words, to what is a relative path passed to log4j relative?  Is this
entirely container-dependent?  If so, can someone with experience with
log4j under JRun4 tell me how (system-independently) to make the logfile
come up in the jrun/logs directory?
-----------------------------------------------
Steve Cohen
Sr. Software Engineer
Sportvision Inc.
scohen@sportvision.com
http://www.sportvision.com

Please note: As a result of the merger of 
Ignite Sports and Sportvision, my email address 
has changed to scohen@sportvision.com


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


Re: controlling the location of log files

Posted by Steve Ebersole <st...@austin.rr.com>.
As with all java processes, a relative file path will be interpreted as
relative from the current working directory (i.e., the directory from which
the process was created).  However, that is not always the directory you
were in when you ran the command (weblogic, for example, CDs to its
domain-specific directory before launching the server).

Don't have much experience with JRun, so I cannot say for sure how it works.

However, there is an option to use variable replacement within the log4j
config file.  The basic jist would be to define a java System variable
(either using a -D option on the command line used to start the process, or
explicitly calling System.setProperty() in your code) and then referencing
that variable in the config.  So for example:
1) start your process with java -Dlog4j.log.dir=<your path to "jrun/logs">
2) use ${log4j.log.dir} where you want to define the relative path; like
${log4j.log.dir}/myLogFile.log


Just FYI, if you decide to use this approach and try to use the
System.setProperty call, make sure the System.setProperty call is done
before log4j gets configured.

HTH


----- Original Message -----
From: "Steve Cohen" <SC...@sportvision.com>
To: "Log4J Users List" <lo...@jakarta.apache.org>
Sent: Wednesday, February 19, 2003 5:19 PM
Subject: controlling the location of log files


Is there a way, without writing system-dependent absolute paths in the
log4j configuration file to control where log4j puts the logs?  In other
words, to what is a relative path passed to log4j relative?  Is this
entirely container-dependent?  If so, can someone with experience with
log4j under JRun4 tell me how (system-independently) to make the logfile
come up in the jrun/logs directory?
-----------------------------------------------
Steve Cohen
Sr. Software Engineer
Sportvision Inc.
scohen@sportvision.com
http://www.sportvision.com

Please note: As a result of the merger of
Ignite Sports and Sportvision, my email address
has changed to scohen@sportvision.com


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



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