I doubt there is a simple solution for redirecting stdout/stderr over
the network. But log4j does have a built-in mechanism to log over the
network.
I am running the org.apache.log4j.net.SocketServer on a machine called
log.donorschoose.org, and the Tomcat on w1.donorschoose.org, etc. logs
to that central log machine. The log entries show up a little delayed,
but it does work.
>From the script that runs on the central log.donorschoose.org machine:
# Which port to listen on?
LOG4J_SERVER_PORT=8888
# Which file holds the settings for the server itself?
LOG4J_SERVER_CONFIG_FILE="/mnt/fs/batch/config/log4j-server.properties"
# Which directory holds the lcf configurations for individual
clients?
# If there is no lcf, defaults to LOG4J_SERVER_CONFIG_FILE settings.
LOG4J_SERVER_CONFIG_DIR="/mnt/fs/batch/config"
java -cp /mnt/fs/src/production/war/WEB-INF/lib/log4j-1.2.9.jar \
org.apache.log4j.net.SocketServer \
$LOG4J_SERVER_PORT \
$LOG4J_SERVER_CONFIG_FILE \
$LOG4J_SERVER_CONFIG_DIR
This is the /mnt/fs/batch/config/generic.lcf file that configures what
the SocketServer does with the log4j messages sent from the clients:
# log everything that comes over from the client
log4j.rootCategory=DEBUG, logfile
# logfile appender
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=/mnt/fs/prod/logs/dcs.log
log4j.appender.logfile.Threshold=DEBUG
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
# Do not Truncate if it already exists.
log4j.appender.logfile.Append=true
I use the same settings for the log4j.properties configuration for the
central SocketServer, except for this one line (nothing interesting in
this log -- it's just the SocketServer log messages, not the clients'):
log4j.appender.logfile.File=/mnt/fs/batch/logs/log4j-server.log
Each of our Tomcat applications (i.e., the client-side of this network
logging) is configured to log over the network with these
log4j.properties settings:
log4j.appender.logfile=org.apache.log4j.net.SocketAppender
log4j.appender.logfile.RemoteHost=log.donorschoose.org
log4j.appender.logfile.Port=8888
Everything else in the application log4j.properties is normal, such as
what level to log and how to format messages, etc.
I'm sure you can do more with a non- generic.lcf file, perhaps having
separate log files for each Tomcat host. Certainly you could set up
separate SocketServer processeson your log machine. I just didn't feel
I needed that.
David Crane
DonorsChoose.org
-----Original Message-----
From: Lynn Hollerman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2008 9:29 AM
To: Tomcat Users List
Subject: logging
I have been asked to see about redirecting the output logs from the
various tomcat instances(all are v5.0 and up) we use. My boss would like
the logs to be written to a different machine on our Unix network. How
would I go about redirecting stdout and stderr in this case?
Thanks!
--
Lynn Hollerman.
Office of Information Systems
University of Louisiana - Lafayette
337-482-6466
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]