org.log5j
Class Logger

java.lang.Object
  extended by org.log5j.Logger

public final class Logger
extends java.lang.Object

The core class of the log5j package. All Loggers are instantiated from the static getLogger(Object) method of this class. The various other public methods allow the programmer to add logging at several levels from trace(Object) to fatal(Object).

Author:
Bruce Ashton

Field Summary
static java.lang.String VERSION
          The log5j version string.
 
Method Summary
 void debug(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is DEBUG or lower.
 void debug(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is DEBUG or lower.
 void debugf(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is DEBUG or lower.
 void error(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is ERROR or lower.
 void error(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is DEBUG or lower.
 void errorf(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is ERROR or lower.
 void fatal(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is FATAL or lower.
 void fatal(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is FATAL or lower.
 void fatalf(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is FATAL or lower.
static Logger getLogger(java.lang.Object object)
          Return the Logger for the given argument.
 void info(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is INFO or lower.
 void info(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is INFO or lower.
 void infof(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is INFO or lower.
 boolean isDebug()
          Return true if the value for this Logger is DEBUG or less
 boolean isError()
          Return true if the value for this Logger is ERROR or less
 boolean isFatal()
          Return true if the value for this Logger is FATAL or less
 boolean isInfo()
          Return true if the value for this Logger is INFO or less
 boolean isLevel(Level level)
          Return true if the value for this Logger is less than or equal to level.value
 boolean isTrace()
          Return true if the value for this Logger is TRACE or less
 boolean isWarn()
          Return true if the value for this Logger is WARN or less
 void log(Level level, java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is equal to or lower than the level.
 void log(Level level, java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is equal to or lower than the level.
 void logf(Level level, java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is equal to or lower than the level.
 java.lang.String toString()
           
 void trace(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is TRACE or lower.
 void trace(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is TRACE or lower.
 void tracef(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is TRACE or lower.
 void warn(java.lang.Object... objects)
          Log a message for a number of objects or primitives if the logging priority is WARN or lower.
 void warn(java.lang.Object object)
          Log a message for a single object or primitive if the logging priority is WARN or lower.
 void warnf(java.lang.String format, java.lang.Object... args)
          Log a formatted message with the given object or primitive arguments if the logging priority is WARN or lower.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
The log5j version string.

See Also:
Constant Field Values
Method Detail

getLogger

public static Logger getLogger(java.lang.Object object)
Return the Logger for the given argument. If one does not exist it will be instantiated at this point.

Parameters:
object - any object or a null
Returns:
the Logger for this object.

debug

public void debug(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is DEBUG or lower.

Parameters:
objects - any number of objects or primitives

debug

public void debug(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is DEBUG or lower.

Parameters:
object - a single object or primitive

debugf

public void debugf(java.lang.String format,
                   java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is DEBUG or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

error

public void error(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is ERROR or lower.

Parameters:
objects - any number of objects or primitives

error

public void error(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is DEBUG or lower.

Parameters:
object - a single object or primitive

errorf

public void errorf(java.lang.String format,
                   java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is ERROR or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

fatal

public void fatal(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is FATAL or lower.

Parameters:
objects - any number of objects or primitives

fatal

public void fatal(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is FATAL or lower.

Parameters:
object - a single object or primitive

fatalf

public void fatalf(java.lang.String format,
                   java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is FATAL or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

info

public void info(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is INFO or lower.

Parameters:
objects - any number of objects or primitives

info

public void info(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is INFO or lower.

Parameters:
object - a single object or primitive

infof

public void infof(java.lang.String format,
                  java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is INFO or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

isDebug

public boolean isDebug()
Return true if the value for this Logger is DEBUG or less

Returns:
true if the value for this Logger is DEBUG or less

isError

public boolean isError()
Return true if the value for this Logger is ERROR or less

Returns:
true if the value for this Logger is ERROR or less

isFatal

public boolean isFatal()
Return true if the value for this Logger is FATAL or less

Returns:
true if the value for this Logger is FATAL or less

isInfo

public boolean isInfo()
Return true if the value for this Logger is INFO or less

Returns:
true if the value for this Logger is INFO or less

isLevel

public boolean isLevel(Level level)
Return true if the value for this Logger is less than or equal to level.value

Parameters:
level - the other Level
Returns:
true if the value for this Logger is less than or equal to level.value

isTrace

public boolean isTrace()
Return true if the value for this Logger is TRACE or less

Returns:
true if the value for this Logger is TRACE or less

isWarn

public boolean isWarn()
Return true if the value for this Logger is WARN or less

Returns:
true if the value for this Logger is WARN or less

log

public void log(Level level,
                java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is equal to or lower than the level.

Parameters:
level - the logging level to test against
objects - any number of objects or primitives

log

public void log(Level level,
                java.lang.Object object)
Log a message for a single object or primitive if the logging priority is equal to or lower than the level.

Parameters:
level - the logging level to test against
object - a single object or primitive

logf

public void logf(Level level,
                 java.lang.String format,
                 java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is equal to or lower than the level.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

trace

public void trace(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is TRACE or lower.

Parameters:
objects - any number of objects or primitives

trace

public void trace(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is TRACE or lower.

Parameters:
object - a single object or primitive

tracef

public void tracef(java.lang.String format,
                   java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is TRACE or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter

warn

public void warn(java.lang.Object... objects)
Log a message for a number of objects or primitives if the logging priority is WARN or lower.

Parameters:
objects - any number of objects or primitives

warn

public void warn(java.lang.Object object)
Log a message for a single object or primitive if the logging priority is WARN or lower.

Parameters:
object - a single object or primitive

warnf

public void warnf(java.lang.String format,
                  java.lang.Object... args)
Log a formatted message with the given object or primitive arguments if the logging priority is WARN or lower.

Formatting for this method is the same as for Formatter.format(String, Object...)

If an exception is thrown in formatting the message, the format string, arguments and the exception are logged without formatting.

Parameters:
format - A format string as described in Formatter string syntax.
args - Arguments referenced by the format specifiers in the format string.
See Also:
Formatter