Skip to content

Instantly share code, notes, and snippets.

@sepgh
Created June 8, 2020 05:07
Show Gist options
  • Save sepgh/bb8c23427cf95c2f17bec9fb697df6a3 to your computer and use it in GitHub Desktop.
Save sepgh/bb8c23427cf95c2f17bec9fb697df6a3 to your computer and use it in GitHub Desktop.
Tomcat log4j2
<Configuration status="error">
<Properties>
<Property name="logdir">${sys:catalina.base}/logs</Property>
<Property name="layout">TOMCAT %d [%t] %-5p %c- %m%n</Property>
</Properties>
<Appenders>
<RollingFile name="CATALINA" fileName="${logdir}/catalina.log" filePattern="${logdir}/catalina.%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${layout}"/>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="1 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="CATALINA"/>
</Root>
<Logger name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]" level="info" additivity="false">
<AppenderRef ref="CATALINA"/>
</Logger>
</Loggers>
</Configuration>
#!/bin/sh
# Run this in tomcat root directory.
# Making directories
mkdir log4j2
cd log4j2
mkdir lib
mkdir conf
# Getting files
cd lib
wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar
wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.11.2/log4j-core-2.11.2.jar
wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-appserver/2.11.2/log4j-appserver-2.11.2.jar
wget https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-jul/2.11.2/log4j-jul-2.11.2.jar
cd ../conf
echo "Add log4j2-tomcat.xml here:"
pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment