Thanks, thats a help but because of the setup of our application, I cant use the 
first two options, and I'd rather not define another properties file just to store 
${CATALINA_HOME}/logs/logs.txt. Is there any way I can do it programatically? What are 
the other options?
 I have searched at the tomcat-user-list archives, and I have even googled for "log4j 
tomcat logs" but without much luck.

 any help would be appreciated

-----Original Message-----
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 1:45 PM
To: Log4J Users List
Subject: RE: Newbie how to place logfile under tomcat logs



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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to