Whenever Log4j documentation says "system properties" it actually refers to any available property source (cf. System properties section). This gives you a rather large spectrum of possibilities.
If you want to set log4j.configuration
globally for all Java applications, set the environment variable LOG4J_CONFIGURATION
.
If you want to set it for all applications running on Tomcat, set a Java system property, by either:
passing the -Dlog4j.configuration=...
option to the JVM as in JRichardsz's answer.
adding the system property to $CATALINA_BASE/conf/catalina.properties
which is sourced by Tomcat just after it sets up its own logging system (see this question),
adding the system property to a log4j2.system.properties
file in Tomcat's server classpath (e.g. $CATALINA_BASE/lib/log4j2.system.properties
), which is sourced by Log4j on startup (cf. source code).
Putting such a file in your application would be bad practice, since the contents of the file end up in Java's system properties and would apply to all applications. If you want to set it for your application only, put it in a log4j2.component.properties
file in your application's classpath.