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: Newbie how to place logfile under tomcat logs
Date Tue, 12 Aug 2003 12:44:42 GMT

Howdy,

> this may be more a tomcat question so appologies if it is off-topic.
> I want to plcae the log file under %TOMCAT_HOME%\logs (where all the
>tomcat logs go).

Reading the archives of this list or the tomcat-user list would've
revealed answers, as this is a fairly common question.

> I have defined in web.xml:
>
>  <servlet>
>     <servlet-name>MyServlet</servlet-name>
>     <servlet-class>foo.bar.MyServlet</servlet-class>
>    <init-param>
>      <param-name>logfile</param-name>
>      <param-value>logs.txt</param-value>
>    </init-param>
>  </servlet>
>
>and in the servlet:
>
>        String logFile = getInitParameter("logfile");
>        appender = new FileAppender(layout, logFile);

You have a number of options, including:

- Setting param-value in web.xml to be an ant token, e.g.
<param-value>@logFilePath@</param-value>
and have Ant fill in this token from whatever properly you want, e.g.
$CATALINA_HOME/logs/logs.txt, when it's deploying web.xml.

- Adding -DCATALINA_HOME=$CATALINA_HOME to your JAVA_OPTS in
$CATALINA_HOME/bin/catalina.sh so that you can get Catalina home via
System.getProperty(), then do 
String logFile = System.getProperty("CATALINA_HOME") + "/logs/" +
getInitParameter("logFile");

- Using a log4j configuration file, rather than programmatic
configuration, and having something like
log4j.myAppender=org.apache.log4j.FileAppender
log4j.myAppneder.File=${CATALINA_HOME}/logs/logs.txt
...

There are other options as well.

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


Mime
View raw message