com.sdm.quasar.client.log4j.common.logging.impl
Class Log4JLogHandler

java.lang.Object
  extended bycom.sdm.quasar.client.log4j.common.logging.impl.Log4JLogHandler
All Implemented Interfaces:
LogHandler

public class Log4JLogHandler
extends java.lang.Object
implements LogHandler


Field Summary
static java.lang.String DEFAULT_MESSAGE_PATTERN
          The default message pattern used to format log messages.
 
Constructor Summary
Log4JLogHandler()
          Creates a new Log4JLogHandler.
Log4JLogHandler(Logger log4jLogger)
          Creates a new Log4JLogHandler.
Log4JLogHandler(Logger log4jLogger, java.lang.String messagePattern, int[] errorLoggingLevels)
          Creates a new Log4JLogHandler.
Log4JLogHandler(java.lang.String messagePattern, int[] errorLoggingLevels)
          Creates a new Log4JLogHandler.
 
Method Summary
 java.lang.String getMessagePattern()
          Returns the message format pattern used to format log messages.
 boolean handles(int loggingLevel, CallerInformation callerInformation)
          Returns true, if the LogHandler can handle logging messages for the calling logger and logging level.
 boolean isErrorLoggingLevel(int loggingLevel)
          Returns true, if the given logging level is an 'error' logging level or a normal one.
 boolean isLogging(int loggingLevel, CallerInformation callerInformation)
          Tests, whether messages will be logged at the given logging level
 void log(int loggingLevel, CallerInformation callerInformation, java.lang.String message, java.lang.Throwable exception)
          Logs a message including an optional exception if logging is enabled for the specified calling logger and logging level.
 void setMessagePattern(java.lang.String messagePattern)
          Sets the message format pattern used to format log messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MESSAGE_PATTERN

public static final java.lang.String DEFAULT_MESSAGE_PATTERN
The default message pattern used to format log messages.

See Also:
Constant Field Values
Constructor Detail

Log4JLogHandler

public Log4JLogHandler()
Creates a new Log4JLogHandler. The Log4J Root Logger will be used (see Logger#getRootLogger().


Log4JLogHandler

public Log4JLogHandler(java.lang.String messagePattern,
                       int[] errorLoggingLevels)
Creates a new Log4JLogHandler. The Log4J Root Logger will be used (see Logger#getRootLogger().

Parameters:
messagePattern - the message-patter to use (if null, use default)
errorLoggingLevels - the logging levels, that should be used as error logging levels (if null, use default)

Log4JLogHandler

public Log4JLogHandler(Logger log4jLogger)
Creates a new Log4JLogHandler.

Parameters:
log4jLogger - The Log4J Logger that will be used.

Log4JLogHandler

public Log4JLogHandler(Logger log4jLogger,
                       java.lang.String messagePattern,
                       int[] errorLoggingLevels)
Creates a new Log4JLogHandler. The Log4J Root Logger will be used (see Logger#getRootLogger().

Parameters:
log4jLogger - The Log4J Logger that will be used.
messagePattern - the message-patter to use (if null, use default)
errorLoggingLevels - the logging levels, that should be used as error logging levels (if null, use default)
Method Detail

handles

public boolean handles(int loggingLevel,
                       CallerInformation callerInformation)
Description copied from interface: LogHandler
Returns true, if the LogHandler can handle logging messages for the calling logger and logging level.

Specified by:
handles in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
Returns:
true, iff this LogHandler can handle logging messages for the logger class and logging level given
See Also:
de.bafa.jfee.common.logging.LogHandler#handles(int, de.bafa.jfee.common.logging.CallerInformation)

isLogging

public boolean isLogging(int loggingLevel,
                         CallerInformation callerInformation)
Description copied from interface: LogHandler
Tests, whether messages will be logged at the given logging level

Specified by:
isLogging in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
Returns:
true, iff messages will be logged at the given level
See Also:
de.bafa.jfee.common.logging.LogHandler#isLogging(int, de.bafa.jfee.common.logging.CallerInformation)

log

public void log(int loggingLevel,
                CallerInformation callerInformation,
                java.lang.String message,
                java.lang.Throwable exception)
Description copied from interface: LogHandler
Logs a message including an optional exception if logging is enabled for the specified calling logger and logging level.

Specified by:
log in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
message - the message to be logged (may be null)
exception - the exception to be logged (may be null)
See Also:
de.bafa.jfee.common.logging.LogHandler#log(int, de.bafa.jfee.common.logging.CallerInformation, java.lang.String, java.lang.Throwable)

isErrorLoggingLevel

public boolean isErrorLoggingLevel(int loggingLevel)
Returns true, if the given logging level is an 'error' logging level or a normal one.

Parameters:
loggingLevel - the logging level to check
Returns:
true if the logging level should be logged as error, false otherwise.

getMessagePattern

public java.lang.String getMessagePattern()
Returns the message format pattern used to format log messages.

Returns:
the message format pattern.

setMessagePattern

public void setMessagePattern(java.lang.String messagePattern)
Sets the message format pattern used to format log messages.