[Deploying Sakai] [Building Sakai] Sakai CLE, log4j, and Tomcat logs
Robert Cohen
robert.cohen at anu.edu.au
Thu Feb 16 15:55:41 PST 2012
We use the following trivial patch to tomcat to get it to log to cronolog.
Which does the logging to a separate file each day.
And maintains a symlink to the current log for ease of access.
If you want to automatically prune the older logs, a cronjob to delete logs
older than N days is trivial.
diff -ur apache-tomcat-5.5.33.orig/bin/catalina.sh
apache-tomcat-5.5.33/bin/catalina.sh
--- apache-tomcat-5.5.33.orig/bin/catalina.sh 2011-04-05 14:38:55.000000000
+1000
+++ apache-tomcat-5.5.33/bin/catalina.sh 2011-04-05 14:41:31.000000000 +1000
@@ -299,7 +299,7 @@
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" start \
- >> "$CATALINA_OUT" 2>&1 &
+ | /usr/sbin/cronolog -S "$CATALINA_OUT"
"${CATALINA_BASE}/logs/catalina.%Y-%m-%d.out" &
if [ ! -z "$CATALINA_PID" ]; then
echo $! > $CATALINA_PID
@@ -311,7 +311,7 @@
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" start \
- >> "$CATALINA_OUT" 2>&1 &
+ | /usr/sbin/cronolog -S "$CATALINA_OUT"
"${CATALINA_BASE}/logs/catalina.%Y-%m-%d.out" &
if [ ! -z "$CATALINA_PID" ]; then
echo $! > $CATALINA_PID
From: Mike De Simone <michael.desimone at rsmart.com>
Date: Thu, 16 Feb 2012 10:08:40 -0700
To: Seth Theriault <slt at columbia.edu>
Cc: <production at collab.sakaiproject.org>,
<sakai-dev at collab.sakaiproject.org>
Subject: Re: [Building Sakai] [Deploying Sakai] Sakai CLE, log4j, and
Tomcat logs
> Seth,
>
> For our installations, I've put in place a manual log rotate script for
> catalina.out. The main reason was that if tomcat is running and the logfile
> file handle is lost, logging will cease until tomcat is restarted. That might
> be what's happening here.
>
> Basically, I wrote a simple bash script to copy catalina.out to a new file,
> then 'cat /dev/null > catalina.out' to empty the file but preserve the file
> handle. Then we remove files older than a certain # of days.
>
> Caveat: on a very busy server, you could lose a few seconds of logging. This
> timeframe could be lessened by rotating daily instead of weekly, for example,
> allowing the copy to run a little faster.
>
> I've attached the script in case it proves a useful approach for you.
>
> Thanks,
>
> -------------------------------
> Mike DeSimone
> Lead Systems Engineer
> rSmart | 602-490-0473
>
>
> On Thu, Feb 16, 2012 at 09:06, Seth Theriault <slt at columbia.edu> wrote:
>> Hello,
>>
>> [pardon the cross-posting]
>>
>> The short question(s): How are you dealing with your production
>> Tomcat logs? Are you overriding the default log4j.properties with
>> different appenders or the like? Do you ever "lose" Tomcat logs?
>>
>> Locally on Sakai 2.8, we override the default log4j.properties to
>> send our Tomcat logs to a logs directory on each app server:
>>
>> [...]
>> # Use "daily" instead of "Sakai"
>> log4j.rootLogger=INFO,daily
>>
>> # Configuration for a daily rolling log file
>> log4j.appender.daily=org.apache.log4j.DailyRollingFileAppender
>> log4j.appender.daily.DatePattern='.'yyyy-MM-dd
>> log4j.appender.daily.File=/var/log/sakai.log
>> log4j.appender.daily.layout=org.apache.log4j.PatternLayout
>> log4j.appender.daily.layout.ConversionPattern=%d %-5p [%t] [%c]: %m%n
>> log4j.appender.daily.Encoding=UTF-8
>> [...]
>>
>> This config works fine for the first 24 hours after Sakai is
>> started, but soon after the first log rotation, it becomes
>> unclear which log file (sakai.log or a sakai.log.yyy-MM-dd) Sakai
>> is actually logging to. After a few days, it doesn't appear to
>> be logging to any file at all. A quick "lsof -p <sakaipid>" often
>> shows multiple log files open.
>>
>> Obviously, this is frustrating. I have thought about sending
>> everything over syslog to a different server, but that's not
>> really practical in my environment.
>>
>> One option that I have been toying with most recently is
>> replacing Sakai's log4j back-end with Logback, its successor:
>>
>> http://logback.qos.ch/
>>
>> Logback relies on SLF4J, a widely used logging abstraction layer,
>> that we already using via its legacy API bridges:
>>
>> http://www.slf4j.org/legacy.html
>>
>> in the kernel and some of the Wicket-based tools.
>>
>> This requires a bit of work (and the licensing needs to be
>> checked into), so I'd be interested in hearing what everyone else
>> does first.
>>
>> Seth
>>
>> _______________________________________________
>> production mailing list
>> production at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/production
>>
>> TO UNSUBSCRIBE: send email to production-unsubscribe at collab.sakaiproject.org
>> with a subject of "unsubscribe"
>
> _______________________________________________ sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev TO UNSUBSCRIBE: send
> email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
> "unsubscribe"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/production/attachments/20120217/810ce2a2/attachment.html
More information about the production
mailing list