Package: tomcat6
Severity: wishlist
Tags: patch

Hi,

Please find attached a patch against current git that adds logfile compression 
to the existing tomcat6 cron.daily script. We've found compression highly 
effective on these kinds of logs, reducing the daily logs from 200 GB to 2 GB, 
a 99% saving.

I've enabled it by default, because of the signifcant savings but also because 
other logs on Debian systems are compressed by default (syslog, Apache to name 
a few).


Cheers,
Thijs

-- 
Thijs Kinkhorst <th...@uvt.nl> – LIS Unix

Universiteit van Tilburg – Library and IT Services • Postbus 90153, 5000 LE
Bezoekadres > Warandelaan 2 • Tel. 013 466 3035 • G 236 • http://www.uvt.nl
From c3d0f9ed145c9b851dc3939c61940614413dd8e8 Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <th...@debian.org>
Date: Fri, 27 Jul 2012 11:50:22 +0200
Subject: [PATCH] Add gzip compression to cron.daily for logs older than today's one.

Compression is very effective on the kind of logging Tomcat produces
thus it's enabled by default, also to match the behaviour of e.g.
syslog and Apache log compression. Nonetheless the admin can disable
it with the LOGFILE_COMPRESS setting in /etc/tomcat6/default.
---
 debian/defaults.template  |    2 ++
 debian/tomcat6.cron.daily |   11 ++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/debian/defaults.template b/debian/defaults.template
index 416312c..3ef3280 100644
--- a/debian/defaults.template
+++ b/debian/defaults.template
@@ -33,6 +33,8 @@ JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC"
 
 # Number of days to keep logfiles in /var/log/tomcat6. Default is 14 days.
 #LOGFILE_DAYS=14
+# Whether to compress logfiles older than today's
+#LOGFILE_COMPRESS=1
 
 # Location of the JVM temporary directory
 # WARNING: This directory will be destroyed and recreated at every startup !
diff --git a/debian/tomcat6.cron.daily b/debian/tomcat6.cron.daily
index 016018c..a585050 100644
--- a/debian/tomcat6.cron.daily
+++ b/debian/tomcat6.cron.daily
@@ -2,11 +2,14 @@
 
 NAME=tomcat6
 DEFAULT=/etc/default/$NAME
+LOGEXT=log
 
 # The following variables can be overwritten in $DEFAULT
 
 # Default for number of days to keep old log files in /var/log/tomcatN/
 LOGFILE_DAYS=14
+# Whether to compress logfiles older than today's
+LOGFILE_COMPRESS=1
 
 # End of variables that can be overwritten in $DEFAULT
 
@@ -16,6 +19,12 @@ if [ -f "$DEFAULT" ]; then
 fi
 
 if [ -d /var/log/$NAME ]; then
-	find /var/log/$NAME/ -name \*.log -mtime +$LOGFILE_DAYS -print0 \
+	if [ $LOGFILE_COMPRESS = 1 ]; then
+		find /var/log/$NAME/ -name \*.$LOGEXT -daystart -mtime +0 -print0 \
+			| xargs --no-run-if-empty -0 gzip -9
+		LOGEXT=log.gz
+	fi
+
+	find /var/log/$NAME/ -name \*.$LOGEXT -mtime +$LOGFILE_DAYS -print0 \
 		| xargs --no-run-if-empty -0 rm --
 fi
-- 
1.7.2.5

Attachment: signature.asc
Description: This is a digitally signed message part.

__
This is the maintainer address of Debian's Java team
<http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-maintainers>. 
Please use
debian-j...@lists.debian.org for discussions and questions.

Reply via email to