ad*@domainthenet.com (Adi) wrote:
Hi,
I have a web application (using J2EE) which runs on 3 tomcats (4.0)
for Load Balancing.
I have recently started to use the Log4j in this application.
Currently the logs for this application is of the
tomcat's(System.out.println...) - and because there are 3 tomcats
there are 3 logs.
The log4j writes to one file only.
My question is:
How can I tell in the log4j log from which server the request came
from?
Thanks,
Adi.
Dude,
The documentation to Log4J specifies that you should place the
log4j.properties file in the WEB-INF/classes directory for your web
application. Every web application deployed under the C:\Tomcat 5.0.19
\webapps directory should have it's own WEB-INF/classes directory. Hence,
every application can independently be assigned it's own log file using
Log4J.
The "log4j.properties" file also allows you to dynamically target which
directory you want to put your Error log and Debug log.
For your Error log, go to the Rolling File Appender section for errors
and modify the line:
log4j.appender.roll-error.File=
C:/Tomcat 5.0.19/webapps/MyPortal/Logs/error.log
For your Debug log, go to the Rolling File Appender section for debug and
modify the line:
log4j.appender.roll-debug.File=
C:/Tomcat 5.0.19/webapps/MyPortal/Logs/debug.log
Of course the location and the name of the error and debug log files can
be any location and file name that you choose. Chances are, your
log4j.properties files are all pointing to the same location.
All I know is that I have several web applications under the C:/Tomcat
5.0.19/webapps directory, and each uses it's own log file depending on
the naming convention I use with the log4j.appender.roll-debug.File=
parameter.
Later