org.openejb.util
Class Logger

java.lang.Object
  extended by org.openejb.util.Logger

public class Logger
extends java.lang.Object

This is a wrapper class to the log4j facility. In addition to the internationalization of messages, it sets a default log4j configuration, if one is not already set in the system properties.

If the log4j system complains that there is no configuration set, then it's probably one of two things. First, the config file does not exist. Second, and more likely, the OpenEJB URL handler has not been registered. (Note that the log4j.configuration default setting uses the protocol resource.)

TODO: Create a wrapper to Tomcat logging facility; Make Logger class a factory

Version:
$Revision: 2059 $ $Date: 2005-08-04 13:17:43 -0700 (Thu, 04 Aug 2005) $
Author:
Alan Cabrera

Nested Class Summary
 class Logger.I18N
           
 
Field Summary
protected  org.apache.log4j.Category _logger
           
protected static java.util.HashMap _loggers
           
 Logger.I18N i18n
           
 
Constructor Summary
protected Logger(java.lang.String resourceName)
          Protected constructor.
 
Method Summary
 void debug(java.lang.String message)
          A wrapper call to log4j's debug method
 void debug(java.lang.String message, java.lang.Throwable t)
          An wrapper call to log4j's debug method
 void error(java.lang.String message)
          A wrapper call to log4j's error method
 void error(java.lang.String message, java.lang.Throwable t)
          An wrapper call to log4j's error method
 void fatal(java.lang.String message)
          A wrapper call to log4j's error method
 void fatal(java.lang.String message, java.lang.Throwable t)
          An wrapper call to log4j's fatal method
static Logger getInstance(java.lang.String category, java.lang.String resourceName)
          Returns a shared instance of Logger.
 void info(java.lang.String message)
          A wrapper call to log4j's error method
 void info(java.lang.String message, java.lang.Throwable t)
          An wrapper call to log4j's info method
static void initialize(java.util.Properties props)
           
 boolean isDebugEnabled()
          Wrapper function for log4j's isDebugEnabled() method.
 boolean isErrorEnabled()
          Check to see if error messages are enabled.
 boolean isFatalEnabled()
          Check to see if fatal messages are enabled.
 boolean isInfoEnabled()
          Wrapper function for log4j's isInfoEnabled() method.
 boolean isWarningEnabled()
          Check to see if warning messages are enabled.
 void warning(java.lang.String message)
          A wrapper call to log4j's warning method
 void warning(java.lang.String message, java.lang.Throwable t)
          An wrapper call to log4j's warning method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_loggers

protected static final java.util.HashMap _loggers

_logger

protected org.apache.log4j.Category _logger

i18n

public Logger.I18N i18n
Constructor Detail

Logger

protected Logger(java.lang.String resourceName)
Protected constructor. Users must invoke getInstance() to an instance of Logger.

Parameters:
resourceName - the name of the log4j category to use
See Also:
Logger.I18N
Method Detail

initialize

public static void initialize(java.util.Properties props)

getInstance

public static Logger getInstance(java.lang.String category,
                                 java.lang.String resourceName)
Returns a shared instance of Logger.

Parameters:
category - the class whose name log4j category will use
resourceName - the name log4j category will use
Returns:
Instance of logger.

isDebugEnabled

public boolean isDebugEnabled()
Wrapper function for log4j's isDebugEnabled() method.

Returns:
if debug is enabled.

isErrorEnabled

public boolean isErrorEnabled()
Check to see if error messages are enabled.

Returns:
if error messages are enabled.

isFatalEnabled

public boolean isFatalEnabled()
Check to see if fatal messages are enabled.

Returns:
if fatal messages are enabled.

isInfoEnabled

public boolean isInfoEnabled()
Wrapper function for log4j's isInfoEnabled() method.

Returns:
if info messages are enabled.

isWarningEnabled

public boolean isWarningEnabled()
Check to see if warning messages are enabled.

Returns:
if warning messages are enabled.

debug

public void debug(java.lang.String message)
A wrapper call to log4j's debug method

Parameters:
message - The debug message to be logged.

debug

public void debug(java.lang.String message,
                  java.lang.Throwable t)
An wrapper call to log4j's debug method

Parameters:
message - The debug message to be logged.
t - the exception to log, including its stack trace
See Also:
Messages

error

public void error(java.lang.String message)
A wrapper call to log4j's error method

Parameters:
message - The error message to be logged.

error

public void error(java.lang.String message,
                  java.lang.Throwable t)
An wrapper call to log4j's error method

Parameters:
message - The error message to be logged.
t - the exception to log, including its stack trace
See Also:
Messages

fatal

public void fatal(java.lang.String message)
A wrapper call to log4j's error method

Parameters:
message - The fatal message to be logged.

fatal

public void fatal(java.lang.String message,
                  java.lang.Throwable t)
An wrapper call to log4j's fatal method

Parameters:
message - The fatal message to be logged.
t - the exception to log, including its stack trace
See Also:
Messages

info

public void info(java.lang.String message)
A wrapper call to log4j's error method

Parameters:
message - The info message to be logged.

info

public void info(java.lang.String message,
                 java.lang.Throwable t)
An wrapper call to log4j's info method

Parameters:
message - The info message to be logged.
t - the exception to log, including its stack trace
See Also:
Messages

warning

public void warning(java.lang.String message)
A wrapper call to log4j's warning method

Parameters:
message - The warning message to be logged.

warning

public void warning(java.lang.String message,
                    java.lang.Throwable t)
An wrapper call to log4j's warning method

Parameters:
message - The warning message to be logged.
t - the exception to log, including its stack trace
See Also:
Messages


Copyright © 1999-2011 OpenEJB. All Rights Reserved.