From 5fd9f6ac2435673457f7fa9374be83eacea0484a Mon Sep 17 00:00:00 2001 From: Mario Melara Date: Wed, 7 Oct 2020 16:31:22 -0700 Subject: [PATCH] Logrotate log files from tomcat and metacat Closes ess-dive/ess-dive-project#155 Logrotates catalina.out by using the docker-entrypoint.sh file and executing logrotate upon container start-up. This mounts a configuration file into the container that logrotate will use for rotation settings. Due to the bugs present in DailyLogRollingFile - documented here: https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html It is recommended to use an appender from log4j extras. This causes additional maintenance overhead. Rather than modifying log4j.properties files for metacat and metacat-index, the defaults are kept and the logrotation is done only in `catalina.out`. --- Dockerfile | 3 +++ docker-entrypoint.sh | 7 ++++++- metacat.conf | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 metacat.conf diff --git a/Dockerfile b/Dockerfile index b2cc604..199bbd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,10 +23,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ net-tools \ telnetd \ procps \ + logrotate \ && rm -rf /var/lib/apt/lists/* \ && cp /tmp/metacat.war /tmp/metacat-index.war /usr/local/tomcat/webapps \ && cat /tmp/catalina.properties >> /usr/local/tomcat/conf/catalina.properties +ADD metacat.conf /etc/logrotate.d/ + COPY apply_config.py /usr/local/bin/ RUN ln -s usr/local/bin/apply_config.py / # backwards compat diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7b04147..34260ad 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -18,6 +18,12 @@ if [ "$1" = 'bin/catalina.sh' ]; then sleep 0.1 done + echo + echo '**************************************' + echo "Logrotating catalina.out" + echo '**************************************' + echo + /usr/sbin/logrotate -s /usr/local/tomcat/logs/logrotate-status.log /etc/logrotate.d/metacat.conf METACAT_DEFAULT_WAR=/usr/local/tomcat/webapps/metacat.war METACAT_DIR=/usr/local/tomcat/webapps/${METACAT_APP_CONTEXT} @@ -112,7 +118,6 @@ if [ "$1" = 'bin/catalina.sh' ]; then ADMINPASS=`cat $ADMINPASS_FILE` fi - # Look for the properties file if [ -s $APP_PROPERTIES_FILE ]; then diff --git a/metacat.conf b/metacat.conf new file mode 100644 index 0000000..edb912d --- /dev/null +++ b/metacat.conf @@ -0,0 +1,8 @@ +/usr/local/tomcat/logs/catalina.out { + copytruncate + rotate 12 + compress + missingok + size 100M + dateext +}