Class Level
Defines the default set of levels recognized by the system.
public sealed class Level : IComparable
- Inheritance
-
Level
- Implements
- Inherited Members
Remarks
Each LoggingEvent has an associated Level.
Levels have a numeric Value that defines the relative ordering between levels. Two Levels with the same Value are deemed to be equivalent.
The levels that are recognized by log4net are set for each ILoggerRepository and each repository can have different levels defined. The levels are stored in the LevelMap on the repository. Levels are looked up by name from the LevelMap.
When logging at level INFO the actual level used is not Info but
the value of LoggerRepository.LevelMap["INFO"]. The default value for this is
Info, but this can be changed by reconfiguring the level map.
Each level has a DisplayName in addition to its Name. The DisplayName is the string that is written into the output log. By default the display name is the same as the level name, but this can be used to alias levels or to localize the log output.
Some of the predefined levels recognized by the system are:
Constructors
Level(int, string)
Constructor
public Level(int level, string levelName)
Parameters
levelintInteger value for this level, higher values represent more severe levels.
levelNamestringThe string name of this level.
Remarks
Initializes a new instance of the Level class with the specified level name and value.
Level(int, string, string)
Constructor
public Level(int level, string levelName, string displayName)
Parameters
levelintInteger value for this level, higher values represent more severe levels.
levelNamestringThe string name of this level.
displayNamestringThe display name for this level. This may be localized or otherwise different from the name
Remarks
Initializes a new instance of the Level class with the specified level name and value.
Fields
Alert
The Alert level designates very severe error events. Take immediate action, alerts.
public static readonly Level Alert
Field Value
All
The All level designates the lowest level possible.
public static readonly Level All
Field Value
Critical
The Critical level designates very severe error events. Critical condition, critical.
public static readonly Level Critical
Field Value
Debug
The Debug level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Debug
Field Value
Emergency
The Emergency level designates very severe error events. System unusable, emergencies.
public static readonly Level Emergency
Field Value
Error
The Error level designates error events that might still allow the application to continue running.
public static readonly Level Error
Field Value
Fatal
The Fatal level designates very severe error events that will presumably lead the application to abort.
public static readonly Level Fatal
Field Value
Fine
The Fine level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Fine
Field Value
Finer
The Finer level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Finer
Field Value
Finest
The Finest level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Finest
Field Value
Info
The Info level designates informational messages that highlight the progress of the application at coarse-grained level.
public static readonly Level Info
Field Value
Log4Net_Debug
The Emergency level designates very severe error events. System unusable, emergencies.
public static readonly Level Log4Net_Debug
Field Value
Notice
The Notice level designates informational messages that highlight the progress of the application at the highest level.
public static readonly Level Notice
Field Value
Off
The Off level designates a higher level than all the rest.
public static readonly Level Off
Field Value
Severe
The Severe level designates very severe error events.
public static readonly Level Severe
Field Value
Trace
The Trace level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Trace
Field Value
Verbose
The Verbose level designates fine-grained informational events that are most useful to debug an application.
public static readonly Level Verbose
Field Value
Warn
The Warn level designates potentially harmful situations.
public static readonly Level Warn
Field Value
Properties
DisplayName
Gets the display name of this level.
public string DisplayName { get; }
Property Value
- string
The display name of this level.
Remarks
Gets the display name of this level.
Name
Gets the name of this level.
public string Name { get; }
Property Value
- string
The name of this level.
Remarks
Gets the name of this level.
Value
Gets the value of this level.
public int Value { get; }
Property Value
- int
The value of this level.
Remarks
Gets the value of this level.
Methods
Compare(Level, Level)
Compares two specified Level instances.
public static int Compare(Level l, Level r)
Parameters
Returns
- int
A 32-bit signed integer that indicates the relative order of the two values compared. The return value has these meanings:
Value Meaning Less than zero lis less thanr.Zero lis equal tor.Greater than zero lis greater thanr.
Remarks
Compares two levels.
CompareTo(object)
Compares this instance to a specified object and returns an indication of their relative values.
public int CompareTo(object r)
Parameters
Returns
- int
A 32-bit signed integer that indicates the relative order of the values compared. The return value has these meanings:
Value Meaning Less than zero This instance is less than r.Zero This instance is equal to r.Greater than zero This instance is greater than
r.-or-
ris null.
Remarks
Exceptions
- ArgumentException
ris not a Level.
Equals(object)
Compares levels.
public override bool Equals(object o)
Parameters
oobjectThe object to compare against.
Returns
- bool
trueif the objects are equal.
Remarks
Compares the levels of Level instances, and defers to base class if the target object is not a Level instance.
GetHashCode()
Returns a hash code
public override int GetHashCode()
Returns
Remarks
Returns a hash code suitable for use in hashing algorithms and data structures like a hash table.
Returns the hash code of the level Value.
ToString()
public override string ToString()
Returns
Remarks
Returns the level Name.
Operators
operator ==(Level, Level)
Returns a value indicating whether two specified Level objects have the same value.
public static bool operator ==(Level l, Level r)
Parameters
Returns
- bool
trueif the value oflis the same as the value ofr; otherwise,false.
Remarks
Compares two levels.
operator >(Level, Level)
public static bool operator >(Level l, Level r)
Parameters
Returns
- bool
trueiflis greater thanr; otherwise,false.
Remarks
Compares two levels.
operator >=(Level, Level)
Returns a value indicating whether a specified Level is greater than or equal to another specified Level.
public static bool operator >=(Level l, Level r)
Parameters
Returns
- bool
trueiflis greater than or equal tor; otherwise,false.
Remarks
Compares two levels.
operator !=(Level, Level)
Returns a value indicating whether two specified Level objects have different values.
public static bool operator !=(Level l, Level r)
Parameters
Returns
- bool
trueif the value oflis different from the value ofr; otherwise,false.
Remarks
Compares two levels.
operator <(Level, Level)
public static bool operator <(Level l, Level r)
Parameters
Returns
- bool
trueiflis less thanr; otherwise,false.
Remarks
Compares two levels.
operator <=(Level, Level)
Returns a value indicating whether a specified Level is less than or equal to another specified Level.
public static bool operator <=(Level l, Level r)
Parameters
Returns
- bool
trueiflis less than or equal tor; otherwise,false.
Remarks
Compares two levels.