You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Callaghan <gr...@hotmail.com> on 2001/11/21 05:13:37 UTC

Configuring Log4j logfile path to {tomcat}/logs??? - What's a good approach

Hi,

I'm wondering how others are running Tomcat/Struts and configuring Log4j for 
logging via a config file approach, ie so that the log file path/name can be 
set relative to the {tomcat}\logs directory.

I've got an approach working but it seems horrible.  There must be an easier 
way. Comments

[1] Get Application Config File Path from WEB.XML (from Log4jInit Servlet 
parameters in web.xml)
[2] Set this ("<APP>-conf-file-path") as a System Parameter as Config.java 
(used to get config variables) expects this
[3] Initialise Config.java (ie load all application config params in)
[3] Extract Application LOG FILE path (for Log4j) from Application Config 
File
  - set this relative to 2 directories up from ServletContext (ie to get to 
Tomcat/logs)
[4] Set this log file path as a System Parameter (Log4j can then use this)
[5] Initialise Log4j (using Log4j config file path from WEB.XML)
[6] Log4j uses its config file to reference the "MutiChoiceLogFilePath" 
system property
	- ie it contains -: log4j.appender.A2.File=${APPChoiceLogFilePath}

Aside from my approach of using a general purpose "Config.java" class to 
access all application config from a config file, the key seems to be that 
the actual configurable log file path/name needs to be set as a System 
Property to allow the Log4j PropertyConfigurator to access.

Any other ideas in general welcome for how to best source configuration 
parameters for a web app.  I've used a configuration properties file above.

Thanks in advance
Greg

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>