NonStop Servlets for JavaServer Pages (NSJSP) 6.1 System Administrator's Guide
Logging in NSJSP
NonStop Servlets for JavaServer Pages (NSJSP) 6.1 System Administrator’s Guide—596210-006
5-30
Commons Logging
....
public class SampleLoggingClass
{
private static Log _logger =
LogFactory.getLog(SampleLoggingClass.class);
....
....
public void sampleMethod()
{
.....
.....
if(_logger.isDebugEnabled())
{
// Compose the message
_logger.debug(message);
}
_logger.error(error message);
}
}
Commons Logging
The applications use different logging implementations, such as, log4j and
java.util.logging. The logging implementations do not follow any particular
standard. The applications written using one logging implementation must be modified
to switch to any other logging implementation. To overcome this drawback, the actual
logging implementation must be abstracted from the application using the logging
implementation. Commons Logging is the abstraction between the application and the
actual logging implementation.
The Commons Logging package is an ultra-thin bridge between different logging
implementations. An application that is programmed to use the commons-logging
application programming interface (API) can be used with any logging implementation
at runtime.
Commons Logging is one of the components of an Apache Commons project that
provides a layer of abstraction over many popular logging implementations. Using
Commons Logging, you can program to an interface rather than to an implementation.
The main components of Commons Logging are as follows:
Log interface – It provides an interface that is intended to be an independent
abstraction of the underlying logging implementation.
LogFactory – It detects the underlying logging implementation and creates the
log instances for the logging implementation detected.
For more information about Commons Logging, see
http://commons.apache.org/logging/
.










