org.ow2.util.log
Class JDKLogger

java.lang.Object
  extended by org.ow2.util.log.JDKLogger
All Implemented Interfaces:
java.io.Serializable, Log

public class JDKLogger
extends java.lang.Object
implements Log, java.io.Serializable

Logger with I18n and infinite arguments.

Author:
Florent Benoit
See Also:
Serialized Form

Field Summary
static java.lang.String SET_HANDLER
          Property to disable the set of our own handler.
 
Constructor Summary
  JDKLogger(java.lang.Class<?> clazz, org.ow2.util.i18n.I18n i18n)
          Creates a new logger.
protected JDKLogger(java.lang.String className, org.ow2.util.i18n.I18n i18n)
          Creates a new logger.
 
Method Summary
 void debug(java.lang.Object message, java.lang.Object... args)
           Log a message with debug log level.
 void error(java.lang.Object message, java.lang.Object... args)
           Log a message with error log level.
 void fatal(java.lang.Object message, java.lang.Object... args)
           Log a message with fatal log level.
 org.ow2.util.i18n.I18n getI18n()
          Gets the i18n object associated to this logger.
 java.util.logging.Logger getLogger()
           
 void info(java.lang.Object message, java.lang.Object... args)
           Log a message with info log level.
 boolean isDebugEnabled()
           Is debug logging currently enabled?
 boolean isErrorEnabled()
           Is error logging currently enabled?
 boolean isFatalEnabled()
           Is fatal logging currently enabled?
 boolean isInfoEnabled()
           Is info logging currently enabled?
 boolean isTraceEnabled()
           Is trace logging currently enabled?
 boolean isWarnEnabled()
           Is warn logging currently enabled?
protected  java.lang.Object readResolve()
          Used to recreate logger after deserialization.
 void trace(java.lang.Object message, java.lang.Object... args)
           Log a message with trace log level.
 void warn(java.lang.Object message, java.lang.Object... args)
           Log a message with warn log level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_HANDLER

public static final java.lang.String SET_HANDLER
Property to disable the set of our own handler.

See Also:
Constant Field Values
Constructor Detail

JDKLogger

public JDKLogger(java.lang.Class<?> clazz,
                 org.ow2.util.i18n.I18n i18n)
Creates a new logger.

Parameters:
clazz - the class that requires a logger.
i18n - the internationalization object to use, if any.

JDKLogger

protected JDKLogger(java.lang.String className,
                    org.ow2.util.i18n.I18n i18n)
Creates a new logger.

Parameters:
className - the name of the class that requires a logger.
i18n - the internationalization object to use, if any.
Method Detail

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Used to recreate logger after deserialization.

Returns:
a new JDK logger
Throws:
java.io.ObjectStreamException - if object can't be resolved

getLogger

public java.util.logging.Logger getLogger()
Returns:
JDK logger

isDebugEnabled

public boolean isDebugEnabled()

Is debug logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than debug.

Specified by:
isDebugEnabled in interface Log
Returns:
true if it is enabled, else false

isErrorEnabled

public boolean isErrorEnabled()

Is error logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than error.

Specified by:
isErrorEnabled in interface Log
Returns:
true if it is enabled, else false

isFatalEnabled

public boolean isFatalEnabled()

Is fatal logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than fatal.

Specified by:
isFatalEnabled in interface Log
Returns:
true if it is enabled, else false

isInfoEnabled

public boolean isInfoEnabled()

Is info logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than info.

Specified by:
isInfoEnabled in interface Log
Returns:
true if it is enabled, else false

isTraceEnabled

public boolean isTraceEnabled()

Is trace logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than trace.

Specified by:
isTraceEnabled in interface Log
Returns:
true if it is enabled, else false

isWarnEnabled

public boolean isWarnEnabled()

Is warn logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than warn.

Specified by:
isWarnEnabled in interface Log
Returns:
true if it is enabled, else false

getI18n

public org.ow2.util.i18n.I18n getI18n()
Gets the i18n object associated to this logger.

Specified by:
getI18n in interface Log
Returns:
i18n object.

debug

public void debug(java.lang.Object message,
                  java.lang.Object... args)

Log a message with debug log level.

Specified by:
debug in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.

error

public void error(java.lang.Object message,
                  java.lang.Object... args)

Log a message with error log level.

Specified by:
error in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.

fatal

public void fatal(java.lang.Object message,
                  java.lang.Object... args)

Log a message with fatal log level.

Specified by:
fatal in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.

info

public void info(java.lang.Object message,
                 java.lang.Object... args)

Log a message with info log level.

Specified by:
info in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.

trace

public void trace(java.lang.Object message,
                  java.lang.Object... args)

Log a message with trace log level.

Specified by:
trace in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.

warn

public void warn(java.lang.Object message,
                 java.lang.Object... args)

Log a message with warn log level.

Specified by:
warn in interface Log
Parameters:
message - - This could be
  • an entry of an I18n repository
  • a preformated message given to MessageFormat class
  • or a simple object on which toString() method will be called
args - could be empty or contains the object for the formatter (I18n case). To log an exception, the exception must be the last argument.


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.