Package org.apache.logging.log4j
Class Level
- java.lang.Object
-
- org.apache.logging.log4j.Level
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Level>
public final class Level extends java.lang.Object implements java.lang.Comparable<Level>, java.io.Serializable
Levels used for identifying the severity of an event. Levels are organized from most specific to least:Name Description OFF
No events will be logged. FATAL
A fatal event that will prevent the application from continuing. ERROR
An error in the application, possibly recoverable. WARN
An event that might possible lead to an error. INFO
An event for informational purposes. DEBUG
A general debugging event. TRACE
A fine-grained debug message, typically capturing the flow through the application. ALL
All events should be logged. Typically, configuring a level in a filter or on a logger will cause logging events of that level and those that are more specific to pass through the filter. A special level,
ALL
, is guaranteed to capture all levels when used in logging configurations.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Level
ALL
All events should be logged.static java.lang.String
CATEGORY
static Level
DEBUG
A general debugging event.static Level
ERROR
An error in the application, possibly recoverable.static Level
FATAL
A fatal event that will prevent the application from continuing.static Level
INFO
An event for informational purposes.static Level
OFF
No events will be logged.static Level
TRACE
A fine-grained debug message, typically capturing the flow through the application.static Level
WARN
An event that might possible lead to an error.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Level
clone()
int
compareTo(Level other)
boolean
equals(java.lang.Object other)
static Level
forName(java.lang.String name, int intValue)
Retrieves an existing Level or creates on if it didn't previously exist.java.lang.Class<Level>
getDeclaringClass()
static Level
getLevel(java.lang.String name)
Return the Level associated with the name or null if the Level cannot be found.StandardLevel
getStandardLevel()
Gets the standard Level values as an enum.int
hashCode()
int
intLevel()
Gets the integral value of this Level.boolean
isInRange(Level minLevel, Level maxLevel)
Compares this level against the levels passed as arguments and returns true if this level is in between the given levels.boolean
isLessSpecificThan(Level level)
Compares this level against the level passed as an argument and returns true if this level is the same or is less specific.boolean
isMoreSpecificThan(Level level)
Compares this level against the level passed as an argument and returns true if this level is the same or is more specific.java.lang.String
name()
Gets the symbolic name of this Level.static Level
toLevel(java.lang.String level)
Converts the string passed as argument to a level.static Level
toLevel(java.lang.String name, Level defaultLevel)
Converts the string passed as argument to a level.java.lang.String
toString()
static <T extends java.lang.Enum<T>>
TvalueOf(java.lang.Class<T> enumType, java.lang.String name)
Returns the enum constant of the specified enum type with the specified name.static Level
valueOf(java.lang.String name)
Return the Level associated with the name.static Level[]
values()
Return an array of all the Levels that have been registered.
-
-
-
Field Detail
-
OFF
public static final Level OFF
No events will be logged.
-
FATAL
public static final Level FATAL
A fatal event that will prevent the application from continuing.
-
ERROR
public static final Level ERROR
An error in the application, possibly recoverable.
-
WARN
public static final Level WARN
An event that might possible lead to an error.
-
INFO
public static final Level INFO
An event for informational purposes.
-
DEBUG
public static final Level DEBUG
A general debugging event.
-
TRACE
public static final Level TRACE
A fine-grained debug message, typically capturing the flow through the application.
-
ALL
public static final Level ALL
All events should be logged.
-
CATEGORY
public static final java.lang.String CATEGORY
- Since:
- 2.1
- See Also:
- Constant Field Values
-
-
Method Detail
-
intLevel
public int intLevel()
Gets the integral value of this Level.- Returns:
- the value of this Level.
-
getStandardLevel
public StandardLevel getStandardLevel()
Gets the standard Level values as an enum.- Returns:
- an enum of the standard Levels.
-
isInRange
public boolean isInRange(Level minLevel, Level maxLevel)
Compares this level against the levels passed as arguments and returns true if this level is in between the given levels.- Parameters:
minLevel
- The minimum level to test.maxLevel
- The maximum level to test.- Returns:
- True true if this level is in between the given levels
- Since:
- 2.4
-
isLessSpecificThan
public boolean isLessSpecificThan(Level level)
Compares this level against the level passed as an argument and returns true if this level is the same or is less specific.Concretely,
ALL
is less specific thanTRACE
, which is less specific thanDEBUG
, which is less specific thanINFO
, which is less specific thanWARN
, which is less specific thanERROR
, which is less specific thanFATAL
, and finallyOFF
, which is the most specific standard level.- Parameters:
level
- The level to test.- Returns:
- True if this level Level is less specific or the same as the given Level.
-
isMoreSpecificThan
public boolean isMoreSpecificThan(Level level)
Compares this level against the level passed as an argument and returns true if this level is the same or is more specific.Concretely,
FATAL
is more specific thanERROR
, which is more specific thanWARN
, etc., untilTRACE
, and finallyALL
, which is the least specific standard level. The most specific level isOFF
.- Parameters:
level
- The level to test.- Returns:
- True if this level Level is more specific or the same as the given Level.
-
clone
public Level clone() throws java.lang.CloneNotSupportedException
- Throws:
java.lang.CloneNotSupportedException
-
compareTo
public int compareTo(Level other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Level>
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
getDeclaringClass
public java.lang.Class<Level> getDeclaringClass()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
name
public java.lang.String name()
Gets the symbolic name of this Level. Equivalent to callingtoString()
.- Returns:
- the name of this Level.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
forName
public static Level forName(java.lang.String name, int intValue)
Retrieves an existing Level or creates on if it didn't previously exist.- Parameters:
name
- The name of the level.intValue
- The integer value for the Level. If the level was previously created this value is ignored.- Returns:
- The Level.
- Throws:
java.lang.IllegalArgumentException
- if the name is null or intValue is less than zero.
-
getLevel
public static Level getLevel(java.lang.String name)
Return the Level associated with the name or null if the Level cannot be found.- Parameters:
name
- The name of the Level.- Returns:
- The Level or null.
- Throws:
java.lang.IllegalArgumentException
- if the name is null.
-
toLevel
public static Level toLevel(java.lang.String level)
Converts the string passed as argument to a level. If the conversion fails, then this method returnsDEBUG
.- Parameters:
level
- The name of the desired Level.- Returns:
- The Level associated with the String.
-
toLevel
public static Level toLevel(java.lang.String name, Level defaultLevel)
Converts the string passed as argument to a level. If the conversion fails, then this method returns the value ofdefaultLevel
.- Parameters:
name
- The name of the desired Level.defaultLevel
- The Level to use if the String is invalid.- Returns:
- The Level associated with the String.
-
values
public static Level[] values()
Return an array of all the Levels that have been registered.- Returns:
- An array of Levels.
-
valueOf
public static Level valueOf(java.lang.String name)
Return the Level associated with the name.- Parameters:
name
- The name of the Level to return.- Returns:
- The Level.
- Throws:
java.lang.NullPointerException
- if the Level name isnull
.java.lang.IllegalArgumentException
- if the Level name is not registered.
-
valueOf
public static <T extends java.lang.Enum<T>> T valueOf(java.lang.Class<T> enumType, java.lang.String name)
Returns the enum constant of the specified enum type with the specified name. The name must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Type Parameters:
T
- The enum type whose constant is to be returned- Parameters:
enumType
- theClass
object of the enum type from which to return a constantname
- the name of the constant to return- Returns:
- the enum constant of the specified enum type with the specified name
- Throws:
java.lang.IllegalArgumentException
- if the specified enum type has no constant with the specified name, or the specified class object does not represent an enum typejava.lang.NullPointerException
- ifenumType
orname
arenull
- See Also:
Enum.valueOf(Class, String)
-
-