7.9. Obtaining Commons Logging
Problem
You need to use Commons Logging to develop a system that works under various logging frameworks, including Sun’s logging framework and Apache Log4J.
Solution
Download Commons Logging 1.0.3. Following the steps outlined in
Recipe 1.1, download
“Commons Logging 1.0.3” instead of
Commons Lang. The Commons Logging
archive—commons-logging-1.0.3.zip—will
contain a file named commons-logging.jar. Place
this JAR file in your classpath, and you will be ready to use Commons
Logging.
Discussion
Commons Logging was created for developers who need to create
components or libraries that may need to operate in environments with
different logging frameworks, including Apache Log4J and the built-in
logging framework introduced in Java 1.4. Using Commons Logging, a
component like Commons BeanUtils or Commons Digester can write log
messages to an abstracted Log interface, and
Commons Logging can deal with passing these log messages to whichever
logging framework is available. Commons Logging is used in almost
every Jakarta Commons component.
If you have a Maven project that needs to use Commons Logging, add a
dependency on Commons Logging 1.0.3 with the following section in
project.xml:
<dependencies>
<dependency>
<id>commons-logging</id>
<version>1.0.3</version>
</dependency>
....other dependencies...
</dependencies>See Also
For more information about Commons Logging, see the Commons Logging project site (http://jakarta.apache.org/commons/logging).
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