Package org.apache.logging.log4j
Class Level
java.lang.Object
org.apache.logging.log4j.Level
- All Implemented Interfaces:
Serializable,Comparable<Level>
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LevelAll events should be logged.static final StringCategory to be used by custom levels.static final LevelA general debugging event.static final LevelAn error in the application, possibly recoverable.static final LevelA fatal event that will prevent the application from continuing.static final LevelAn event for informational purposes.static final LevelNo events will be logged.static final LevelA fine-grained debug message, typically capturing the flow through the application.static final LevelAn event that might possible lead to an error. -
Method Summary
Modifier and TypeMethodDescriptionclone()intbooleanstatic LevelRetrieves an existing Level or creates on if it didn't previously exist.static LevelReturn the Level associated with the name or null if the Level cannot be found.Gets the standard Level values as an enum.inthashCode()intintLevel()Gets the integral value of this Level.booleanCompares this level against the levels passed as arguments and returns true if this level is in between the given levels.booleanisLessSpecificThan(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.booleanisMoreSpecificThan(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.name()Gets the symbolic name of this Level.static LevelConverts the string passed as argument to a level.static LevelConverts the string passed as argument to a level.toString()static <T extends Enum<T>>
TReturns the enum constant of the specified enum type with the specified name.static LevelReturn the Level associated with the name.static Level[]values()Return an array of all the Levels that have been registered.
-
Field Details
-
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. -
CATEGORY
Category to be used by custom levels.- Since:
- 2.1
- See Also:
-
-
Method Details
-
intLevel
public int intLevel()Gets the integral value of this Level.- Returns:
- the value of this Level.
-
getStandardLevel
Gets the standard Level values as an enum.- Returns:
- an enum of the standard Levels.
-
isInRange
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
Compares this level against the level passed as an argument and returns true if this level is the same or is less specific.Concretely,
ALLis 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
Compares this level against the level passed as an argument and returns true if this level is the same or is more specific.Concretely,
FATALis 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
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
compareTo
- Specified by:
compareToin interfaceComparable<Level>
-
equals
-
getDeclaringClass
-
hashCode
public int hashCode() -
name
Gets the symbolic name of this Level. Equivalent to callingtoString().- Returns:
- the name of this Level.
-
toString
-
forName
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:
IllegalArgumentException- if the name is null or intValue is less than zero.
-
getLevel
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:
IllegalArgumentException- if the name is null.
-
toLevel
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
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
Return an array of all the Levels that have been registered.- Returns:
- An array of Levels.
-
valueOf
Return the Level associated with the name.- Parameters:
name- The name of the Level to return.- Returns:
- The Level.
- Throws:
NullPointerException- if the Level name isnull.IllegalArgumentException- if the Level name is not registered.
-
valueOf
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- theClassobject 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:
IllegalArgumentException- if the specified enum type has no constant with the specified name, or the specified class object does not represent an enum typeNullPointerException- ifenumTypeornamearenull- See Also:
-