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


> 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.
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.

$CATALINA_HOME/bin/catalina.sh so that you can get Catalina home via
System.getProperty(), then do 
String logFile = System.getProperty("CATALINA_HOME") + "/logs/" +

- Using a log4j configuration file, rather than programmatic
configuration, and having something like

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

View raw message