[Deploying Sakai] Sakai CLE, log4j, and Tomcat logs

Mike De Simone michael.desimone at rsmart.com
Thu Feb 16 09:08:40 PST 2012


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.


Mike DeSimone
Lead Systems Engineer
*r**Smart* | 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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/production/attachments/20120216/dd77908e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tomcat_logrotate
Type: application/octet-stream
Size: 1123 bytes
Desc: not available
Url : http://collab.sakaiproject.org/pipermail/production/attachments/20120216/dd77908e/attachment.obj 

More information about the production mailing list