Simple Log 2.0.1
[grlea]

org.grlea.log.adapters.slf4j
Class Slf4jAdapter

java.lang.Object
  extended by org.slf4j.impl.MarkerIgnoringBase
      extended by org.grlea.log.adapters.slf4j.Slf4jAdapter
All Implemented Interfaces:
org.slf4j.Logger

public class Slf4jAdapter
extends org.slf4j.impl.MarkerIgnoringBase

An adapter for using Simple Log within the SLF4J package.

Instructions for Use

To use this Slf4jAdapter with SLF4J, you should only need to include the JARs for Simple Log (simple-log.jar) and for the SLF4J Adapter (simple-log-slf4j.jar) in your classpath and use the SLF4J LoggerFactory to obtain log instances. Be careful not to confuse 'slf4j-simple.jar' as being part of the arrangement. It is a SLF4J deliverable that simply prints output to System.out.

Implementation Details

The Slf4jAdapter always uses the default SimpleLog. It is anticipated this will do the job for the preverbial 99% of cases. If this is insufficient for your needs, please write to me and we can try and find a more flexible solution.

The SLF4J levels map directly to the Simple Log levels:

SLF4J Simple Log
Error Error
Warn Warn
Info Info
Debug Debug

"Tracing"

Note that the SLF4J has no notion of tracing whatsoever, so the tracing properties in Simple Log will have no bearing on the output.

Logger Names

The SLF4J API provides logger names that are Strings, while Simple Log prefers Class objects for naming its loggers. This adapter tries to rectify the discord by attempting to interpret logger names as fully qualified class names. Where this is not possible (because the logger name is not a class name), a SimpleLogger will be created using a source class of org.slf4j.Logger and with the provided logger name as the instance ID of the logger. (See SimpleLogger.SimpleLogger(Class, Object). When the two-argument domain + sub-domain method is used and the domain is not a fully-qualified class name, the domain and sub-domain are concatenated with a period ('.') in between, e.g. "domain.subdomain", and this is used as the instance ID. This means that, when writing properties to configure loggers that don't use class names, the properties should take the form:

    org.slf4j.Logger.<logger-name>
or
    org.slf4j.Logger.<domain>.<subdomain>

When logger names cannot be interpreted as class names, each logger name that cannot be interpreted will be printed with a warning to System.err. You can supress these warnings by setting the system property org.grlea.log.adapters.slf4j.supressWarnings to true.

Object Rendering

Messages submitted to the Slf4jAdapter using the format + argument(s) methods are interpreted using the MessageFormatter that is provided in SLF4J.

Version:
$Revision: 1.4 $
Author:
Graham Lea

Method Summary
 void debug(java.lang.String message)
           
 void debug(java.lang.String messageFormat, java.lang.Object argument)
           
 void debug(java.lang.String messageFormat, java.lang.Object[] arguments)
           
 void debug(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
           
 void debug(java.lang.String message, java.lang.Throwable exception)
           
 void error(java.lang.String message)
           
 void error(java.lang.String messageFormat, java.lang.Object argument)
           
 void error(java.lang.String messageFormat, java.lang.Object[] arguments)
           
 void error(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
           
 void error(java.lang.String message, java.lang.Throwable exception)
           
 java.lang.String getName()
           
 void info(java.lang.String message)
           
 void info(java.lang.String messageFormat, java.lang.Object argument)
           
 void info(java.lang.String messageFormat, java.lang.Object[] arguments)
           
 void info(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
           
 void info(java.lang.String message, java.lang.Throwable exception)
           
 boolean isDebugEnabled()
           
 boolean isErrorEnabled()
           
 boolean isInfoEnabled()
           
 boolean isWarnEnabled()
           
 void warn(java.lang.String message)
           
 void warn(java.lang.String messageFormat, java.lang.Object argument)
           
 void warn(java.lang.String messageFormat, java.lang.Object[] arguments)
           
 void warn(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
           
 void warn(java.lang.String message, java.lang.Throwable exception)
           
 
Methods inherited from class org.slf4j.impl.MarkerIgnoringBase
debug, debug, debug, debug, debug, error, error, error, error, error, info, info, info, info, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isWarnEnabled, warn, warn, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()

isErrorEnabled

public boolean isErrorEnabled()

isWarnEnabled

public boolean isWarnEnabled()

isInfoEnabled

public boolean isInfoEnabled()

isDebugEnabled

public boolean isDebugEnabled()

error

public void error(java.lang.String message)

error

public void error(java.lang.String messageFormat,
                  java.lang.Object argument)

error

public void error(java.lang.String messageFormat,
                  java.lang.Object argument1,
                  java.lang.Object argument2)

error

public void error(java.lang.String messageFormat,
                  java.lang.Object[] arguments)

error

public void error(java.lang.String message,
                  java.lang.Throwable exception)

warn

public void warn(java.lang.String message)

warn

public void warn(java.lang.String messageFormat,
                 java.lang.Object argument)

warn

public void warn(java.lang.String messageFormat,
                 java.lang.Object argument1,
                 java.lang.Object argument2)

warn

public void warn(java.lang.String messageFormat,
                 java.lang.Object[] arguments)

warn

public void warn(java.lang.String message,
                 java.lang.Throwable exception)

info

public void info(java.lang.String message)

info

public void info(java.lang.String messageFormat,
                 java.lang.Object argument)

info

public void info(java.lang.String messageFormat,
                 java.lang.Object argument1,
                 java.lang.Object argument2)

info

public void info(java.lang.String messageFormat,
                 java.lang.Object[] arguments)

info

public void info(java.lang.String message,
                 java.lang.Throwable exception)

debug

public void debug(java.lang.String message)

debug

public void debug(java.lang.String messageFormat,
                  java.lang.Object argument)

debug

public void debug(java.lang.String messageFormat,
                  java.lang.Object argument1,
                  java.lang.Object argument2)

debug

public void debug(java.lang.String messageFormat,
                  java.lang.Object[] arguments)

debug

public void debug(java.lang.String message,
                  java.lang.Throwable exception)

Copyright (c) 2004-2006, Graham Lea. All rights reserved.