x4juli - Features and Comparison


Table of Contents

Features
LogManager
Formatter
Handler
Filter
Loggers and LogRecords
Wrapper and Plugin APIs
Comparison

Features

LogManager

The ClassLoaderLogManager has ThreadContextClassLoading support and allows different configurations per classloader. This has advantages in J2EE environments, to configure per webapplication or enterprise application. Loggers are hold with a weak reference, this avoids memory leaks when the server throws away the classloader (for hot-/re-deployment tasks).

Formatter

There are three x4juli formatters, with a common, abstract baseclass which allows user to extend x4juli in an easy way.

  • SimpleFormatter - No configuration needed, just level and message output.

  • PatternFormatter - Most flexible, configurable formatting. Allows to enable/disable output of any information contained in the LogRecord and NestedDiagnosticContext. The layout is also depending on the configuration.

  • HTMLFormatter - Allows direct output as HTML page for viewing per browser.

Handler

There are three main x4juli handlers, with a common, abstract baseclass which allows user to extend x4juli in an easy way. All handlers accept filter chains.

It is possible to configure multiple instances of a handler with different configuration, this is not possible in java.util.logging.

  • ConsoleHandler - Used to log to the system console. Configuration allows to determine System.out or System.err for output.

  • FileHandler - Used to log to a file. Path and filename, appending to/overwriting an existing file, and buffering is configurable.

  • RollingFileHandler - Used to log to a file. Depending on the configuration a new file will be used when a certain file size or time is reached. You can specifiy different locations and names for the active log file and the backuped files. The backuped files can optionally be compressed.

Filter

All filters can be configured to accept or deny a logrecord if the specified criteria are matched. Currently one can configure the filters per programming, not by a config file.

  • LevelMatchFilter - Based on the exact match of the specified filter level to the logrecord's level.

  • LevelRangeFilter - Based on a minimum/maximum range of the filter level to the logrecord's level.

  • StringMatchFilter - Based on a specified String to match against the logrecord's message.

  • DenyAllFilter - Rejects any logrecord.

  • WrapperFilter - A wrapper around a standard java.util.logging filter for use in filter chains.

Loggers and LogRecords

x4juli uses internally extended Logger classes and extended LogRecord classes. These are normally not exposed to user code, which has limitations in the extension of the interface, but allows change without breaking user code.

  • All information of java.util.logging

  • Location Information: java.util.logging has just location information about the class and the method which invoked the logging operation. x4juli has all information: class, method, file, linenumber. Obtaining these information is a expensive task. It is just done, when the user configures x4juli (by the PatternFormatter) to do so!

  • Nested Diagnostic Context: Usefull in J2EE server environments to specify information per thread, i.E. session id, user id, cookie... It is displayed for each logrecord generated in the corresponding thread.

Wrapper and Plugin APIs

x4juli works in the "backend" of java.util.logging. Very few classes for special usecases are needed for user-code. The normal usecase is to have java.util.logging objects and methods in usercode and configure java.util.logging to use x4juli for formatting, filtering and output.

There is also native support for the following APIs:

  • Jakarta Commons Logging (JCL): The X4JuliLogger implements the interface of the JCL Logger. X4Juli delivers a factory for JCL, which can be enabled by an property, either per system property or in an commons-logging.properties file. This avoids wrapper object creation and native extend logrecord generation (behind the interface of JCL).

  • Simple Logging Facade for Java (slf4j): The X4JuliLogger implements the interface of the slf4j Logger. X4Juli delivers currently all classes for slf4j, it is ready to use. You simply have to put x4juli (as described) on the system classpath. This avoids wrapper object creation and native extend logrecord generation (behind the interface of slf4j).

  • JBoss plugin: JBoss has an independent logging system which is wrapper (class!) and plugin based. X4Juli delivers a plugin to have better location information support.

Comparison

The following feature comparison reflects status on end of December, 2005 and compares x4juli with JDK 1.4. The only extension in JDK 1.5 for java.util.logging is the LoggingMXBean interface, so the comparison reflects both versions.

Table 1. Feature Comparison Table

Featurejava.util.loggingx4juli
ClassLoader dependent LogManagerNo, one Map for the whole system.Yes.
Multiple instances of a handler per configuration file.No (sic! look at the API docs).Yes.
Handler's filter configurationSingle filter, no chain.Single filter and filter chain possible.
ConsoleHandlerYes, always System.err.Yes, System.out and System.err depending on config.
FileHandlerYes.Yes, advanced configuration options.
RollingFileHandlerSame class as FileHandler, just allows maximum size for rolling, no max backup limit.Yes, advanced configuration options. Rolling due to size, time. Maximum count of backup files, optional compression, different locations for active log and backup log files.
FiltersJust interface specified, no filter classes per default.Interface and Filters based on level or message per default available. Currently only programmatic configuration.
LoggerDefault implementation. Single filter, no chain.Extended implementation with full location information (just and only when configured by the user). NDC support. Single filter and filter chain possible.
Jakarta Commons LoggingSupport due to default wrapper class in JCL, expensive obtain of location information for every logrecord.Native implementation, optionally activatable by the user. Full location information (just and only when configured by the user).
Simple Logging Facade for JavaSupport due to default wrapper class in slf4j. No correct location information available.Native implementation. All classes provided in the x4juli distribution. Full location information (just and only when configured by the user).
JBoss pluginSupport due to default plugin provided by JBoss. No correct location information available.Advanced plugin delivered in the x4juli distribution, optionally activatable by the user. Full location information (just and only when configured by the user).
Nested diagnostic context (NDC)No.Yes.
System.out and System.err redirectionNo.Yes. (Handle with care to avoid logging loops!)