fedora.utilities
Class Log4JRedirectFilter

java.lang.Object
  extended by fedora.utilities.Log4JRedirectFilter
All Implemented Interfaces:
java.util.logging.Filter

public class Log4JRedirectFilter
extends java.lang.Object
implements java.util.logging.Filter

A Java Logging Filter that redirects LogRecords to a Log4J Logger. This class is useful if your project wants consistent logging configuration based on Log4J, but must work with a library that uses the Java Logging API. By using this filter's convenience method, apply, messages that would otherwise go to Java Logging handler(s) are instead sent to the configured Log4J appender(s). Example use:

     // Causes all messages generated by the org.example.Example 
     // Java Logger to be sent to an equivalently-named Log4J appender.
     Log4JRedirectFilter.apply("org.example.Example");
 
The log level mapping used is as follows:
   Log4J           Java Logging
   ------------    ------------
   OFF             OFF
   ERROR, FATAL    SEVERE
   WARN            WARNING
   INFO            INFO, CONFIG
   DEBUG           FINER, FINE
   TRACE           FINEST
   ALL             ALL
 

Author:
cwilper@cs.cornell.edu

Constructor Summary
Log4JRedirectFilter(org.apache.log4j.Logger log4jLogger)
           
 
Method Summary
static void apply(java.lang.String javaLoggerName)
          Convenience method for applying a Log4JRedirectFilter to a Java Logger, by name.
 boolean isLoggable(java.util.logging.LogRecord record)
          Always returns false, but before doing so, sends the given record to the Log4J Logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JRedirectFilter

public Log4JRedirectFilter(org.apache.log4j.Logger log4jLogger)
Method Detail

apply

public static void apply(java.lang.String javaLoggerName)
Convenience method for applying a Log4JRedirectFilter to a Java Logger, by name. Log records destined for the given Java logger will be redirected to the Log4J logger of the same name.


isLoggable

public boolean isLoggable(java.util.logging.LogRecord record)
Always returns false, but before doing so, sends the given record to the Log4J Logger.

Specified by:
isLoggable in interface java.util.logging.Filter