Apache Commons Logging


Apache Commons Logging is a Java-based logging utility and a programming model for logging and for other toolkits. It provides APIs, log implementations, and wrapper implementations over some other tools.

Log level

The following table defines the log levels and messages in Apache Commons Logging, in decreasing order of severity. The left column lists the log level designation in and the right column provides a brief description of each log level.
LevelDescription
fatalSevere errors that cause premature termination. Expect these to be immediately visible on a status console.
errorOther runtime errors or unexpected conditions. Expect these to be immediately visible on a status console.
warnUse of deprecated APIs, poor use of API, 'almost' errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Expect these to be immediately visible on a status console.
infoInteresting runtime events. Expect these to be immediately visible on a console, so be conservative and keep to a minimum.
debugDetailed information on the flow through the system. Expect these to be written to logs only.
traceMost detailed information. Expect these to be written to logs only.

Configuration

Two basic abstractions, Log and LogFactory, are used in Apache Commons Logging.

Example

Sample code may look like as follows:

package com.cascadetg.ch09;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Jdk14Logger;
public class LogGenerator