Skip to content

Instantly share code, notes, and snippets.

@collinpeters
Created May 31, 2012 20:46
Show Gist options
  • Save collinpeters/2846131 to your computer and use it in GitHub Desktop.
Save collinpeters/2846131 to your computer and use it in GitHub Desktop.
Script to setup log4j for Tomcat internal logging. Uses custom log4j.properties gist as well
#!/bin/sh
# Setup log4j for Tomcat logging as per http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
# @author Collin Peters
# Download log4j.properties
echo "Getting log4j.properties..."
wget -q --output-document /opt/tomcat/lib/log4j.properties https://gist.github.com/collinpeters/2845875/raw/caef85e03e7b586bace0dbc14da17a4f78d1757a/log4j.properties
# Download log4j.tgz and extract jar directly to Tomcat
echo "Downloading log4j-1.2.17.tar.gz and extracting log4j.jar to /opt/tomcat/lib/log4j.jar..."
wget -q http://apache.mirror.iweb.ca/logging/log4j/1.2.17/log4j-1.2.17.tar.gz -O - | tar zxf - -C /opt/tomcat/lib --strip-components=1 --wildcards --no-anchored '*.jar*'
echo "Downloading tomcat-juli-adapters.jar to /opt/tomcat/lib/tomcat-juli-adapters.jar..."
wget -q --output-document=/opt/tomcat/lib/tomcat-juli-adapters.jar http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.47/bin/extras/tomcat-juli-adapters.jar
echo "Downloading tomcat-juli.jar to /opt/tomcat/bin/tomcat-juli.jar ..."
wget -q --output-document=/opt/tomcat/bin/tomcat-juli.jar http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.47/bin/extras/tomcat-juli.jar
echo -n "Renaming logging.properties ... "
mv -v /opt/tomcat/conf/logging.properties /opt/tomcat/conf/logging.properties.bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment