*/rsh tech|
your source for programming know-how
Generated by:
Craftsman

Overview of rsh-logging

Design Goals

The rsh-logging package exists for one reason:

To make logging so simple that developers have no excuse not to use it in all their code.

With that mission in mind, rsh-logging was designed to accomplish two primary goals:

  1. Make using either the JDK Logger or the Log4J Logger simple and hidden from the end user (they shouldn't know or care which one they are using).
  2. Make logging configuration simple and dead-easy no matter what logging toolkit you are using.
In the case of the JDK Logger, the 2nd goal is not possible using JDK 1.4. Despite countless tutorials, many developers still find the JDK logger difficult to use. Log4J expects certain defaults to be present, and if they are not, nothing gets printed to the Console. The rsh-logging package solves both of these problems (and more) by hiding a lot of default configuration and implementation details from the user. They just need to request a logger through LoggingUtil and everything is taken care of for them. If they set some package to level=FINE, it works. If they set another to level=debug, it works.

Component Overview

Diagrams/rsh-logging-overview.png

While there are several classes at work in the rsh-logging package, the only one users care about is the LoggingUtil utility class. This class is used to wrap getting at the Log object. Its purpose is to ensure any configuration steps needed to use the toolkit have been taken before the Log object is returned. Initialization only takes place once, and from there on out, the LoggingUtil uses the Apache Commons Logging package to retrieve a Log object from the underlying toolkit.

Configuration of the toolkit is deferred to the LoggingConfigurator implementations, called through the ConfiguratorUtil class. Any toolkit or framework specific code is contained within these implementations. While you made need both the JDK Logger and Log4J to compile rsh-logging, you only need which ever one you plan on using in order to use rsh-logging. This allows rsh-logging to lean heavily on Java's dynamic loading and linking abilities. Whatever toolkit you use, only then is the toolkit specifc configuration code called (if at all).