7.11. Specifying a Logging Implementation
Problem
You are using a component that writes log messages with Commons Logging, and you need to configure the underlying logging implementation.
Solution
If the system property org.apache.commons.logging.Log
is not set, Commons Logging will use Apache Log4J if it is
available in the classpath. To explicitly configure Commons Logging
to use Log4J, set the
org.apache.commons.logging.Log property to
org.apache.commons.logging.impl.Log4JLogger with
the following statement:
System.setProperty( "org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.Log4JLogger" );If the system property
org.apache.commons.logging.Log is not set and
Apache Log4J is not available on the classpath, Commons Logging will
then use the built-in JDK 1.4 logging framework. To explicitly
configure Commons Logging to use the JDK 1.4 logging framework, set
the org.apache.commons.logging.Log property to
org.apache.commons.logging.impl.Jdk14Logger.
If neither Apache Log4J nor the JDK 1.4 logging framework is
available on the classpath and the
org.apache.commons.logging.Log system property
is not set, Commons Logging uses a basic logging implementation named
SimpleLog. To explicitly configure Commons Logging
to use SimpleLog, set the
org.apache.commons.logging.Log property to
org.apache.commons.logging.impl.SimpleLog.
Discussion
To summarize, Commons Logging performs the following steps when choosing an underlying logging implementation:
Checks the
org.apache.commons.logging.Log ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access