Log4j 1.3alpha-1

org.apache.log4j
Class Level

java.lang.Object
  |
  +--org.apache.log4j.Level
Direct Known Subclasses:
Priority, UtilLoggingLevel

public class Level
extends java.lang.Object

Defines the minimum set of levels recognized by the system, that is OFF, FATAL, ERROR, WARN, INFODEBUG, TRACE, and ALL.

The Level class may be subclassed to define a larger level set.

Author:
Ceki Gülcü, Yoav Shapira

Field Summary
static Level ALL
          The ALL has the lowest possible rank and is intended to turn on all logging.
static int ALL_INT
          ALL level integer value.
static Level DEBUG
          The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
static int DEBUG_INT
          DEBUG level integer value.
static Level ERROR
          The ERROR level designates error events that might still allow the application to continue running.
static int ERROR_INT
          ERROR level integer value.
static Level FATAL
          The FATAL level designates very severe error events that will presumably lead the application to abort.
static int FATAL_INT
          FATAL level integer value.
static Level INFO
          The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
static int INFO_INT
          INFO level integer value.
static Level OFF
          The OFF has the highest possible rank and is intended to turn off logging.
static int OFF_INT
          OFF level integer value.
static Level TRACE
          The TRACE Level designates finer-grained informational events than the DEBUG
static int TRACE_INT
          TRACE level integer value.
static Level WARN
          The WARN level designates potentially harmful situations.
static int WARN_INT
          WARN level integer value.
 
Constructor Summary
protected Level(int level, java.lang.String levelStr, int syslogEquivalent)
          Instantiate a level object.
 
Method Summary
 boolean equals(java.lang.Object o)
          Two Levels (formerly Priorities) are equal if their level integer value fields are equal.
static Level[] getAllPossiblePriorities()
          Deprecated. This method will be removed with no replacement.
 int getSyslogEquivalent()
          Return the syslog equivalent of this priority as an integer.
 int hashCode()
          The hashCode of a Level (i.e.
 boolean isGreaterOrEqual(Level r)
          Returns true if this level has a higher or equal level than the level passed as argument, false otherwise.
 int toInt()
          Returns the integer representation of this level.
static Level toLevel(int val)
          Convert an integer passed as argument to a level.
static Level toLevel(int val, Level defaultLevel)
          Convert an integer passed as argument to a level.
static Level toLevel(java.lang.String sArg)
          Convert the string passed as argument to a level.
static Level toLevel(java.lang.String sArg, Level defaultLevel)
          Convert the string passed as argument to a level.
 java.lang.String toString()
          Returns the string representation of this Level.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OFF_INT

public static final int OFF_INT
OFF level integer value.

See Also:
Constant Field Values

FATAL_INT

public static final int FATAL_INT
FATAL level integer value.

See Also:
Constant Field Values

ERROR_INT

public static final int ERROR_INT
ERROR level integer value.

See Also:
Constant Field Values

WARN_INT

public static final int WARN_INT
WARN level integer value.

See Also:
Constant Field Values

INFO_INT

public static final int INFO_INT
INFO level integer value.

See Also:
Constant Field Values

DEBUG_INT

public static final int DEBUG_INT
DEBUG level integer value.

See Also:
Constant Field Values

TRACE_INT

public static final int TRACE_INT
TRACE level integer value.

See Also:
Constant Field Values

ALL_INT

public static final int ALL_INT
ALL level integer value.

See Also:
Constant Field Values

OFF

public static final Level OFF
The OFF has the highest possible rank and is intended to turn off logging.


FATAL

public static final Level FATAL
The FATAL level designates very severe error events that will presumably lead the application to abort.


ERROR

public static final Level ERROR
The ERROR level designates error events that might still allow the application to continue running.


WARN

public static final Level WARN
The WARN level designates potentially harmful situations.


INFO

public static final Level INFO
The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.


DEBUG

public static final Level DEBUG
The DEBUG Level designates fine-grained informational events that are most useful to debug an application.


TRACE

public static final Level TRACE
The TRACE Level designates finer-grained informational events than the DEBUG

ALL

public static final Level ALL
The ALL has the lowest possible rank and is intended to turn on all logging.

Constructor Detail

Level

protected Level(int level,
                java.lang.String levelStr,
                int syslogEquivalent)
Instantiate a level object.

Parameters:
level - The integer level value
levelStr - The level name
syslogEquivalent - The UNIX SystLog level equivalent
Method Detail

toLevel

public static Level toLevel(java.lang.String sArg)
Convert the string passed as argument to a level. If the conversion fails, then this method returns DEBUG.

Parameters:
sArg - The level name
Returns:
The matching Level object

toLevel

public static Level toLevel(int val)
Convert an integer passed as argument to a level. If the conversion fails, then this method returns DEBUG.

Parameters:
val - The level integer value
Returns:
The matching Level object

equals

public boolean equals(java.lang.Object o)
Two Levels (formerly Priorities) are equal if their level integer value fields are equal. If the argument is not a Level, this method returns False.

Overrides:
equals in class java.lang.Object
Parameters:
o - The other Level
Returns:
boolean True if equals
Since:
1.2

hashCode

public int hashCode()
The hashCode of a Level (i.e. Priority) is its level field.

Overrides:
hashCode in class java.lang.Object
Returns:
The integer level value

getSyslogEquivalent

public final int getSyslogEquivalent()
Return the syslog equivalent of this priority as an integer.

Returns:
The UNIX SysLog equivalent

isGreaterOrEqual

public boolean isGreaterOrEqual(Level r)
Returns true if this level has a higher or equal level than the level passed as argument, false otherwise.

You should think twice before overriding the default implementation of isGreaterOrEqual method.


getAllPossiblePriorities

public static Level[] getAllPossiblePriorities()
Deprecated. This method will be removed with no replacement.

Return all possible priorities as an array of Level objects in descending order.

Returns:
Level[] All the Levels

toString

public final java.lang.String toString()
Returns the string representation of this Level.

Overrides:
toString in class java.lang.Object
Returns:
String The Level name

toInt

public final int toInt()
Returns the integer representation of this level.


toLevel

public static Level toLevel(int val,
                            Level defaultLevel)
Convert an integer passed as argument to a level. If the conversion fails, then this method returns the specified default.

Parameters:
val - The integer value
defaultLevel - The Level to return if no match is found
Returns:
The matching Level

toLevel

public static Level toLevel(java.lang.String sArg,
                            Level defaultLevel)
Convert the string passed as argument to a level. If the conversion fails, then this method returns the defaultLevel.

Parameters:
sArg - The Level name
defaultLevel - Level to return if no match is found
Returns:
The matching Level

Log4j 1.3alpha-1

Copyright 2000-2003 Apache Software Foundation.