Reputation: 5452
I need to configure Threshold dynamically in run-time, I might have integer or string representation of the level in .net variable. Instead of getting one of this representations, log4net expects both them to be specified in constructor, which seems very weird to me:
public Level(int level, string levelName);
log4net team did not even trouble to explain why, all I found is this:
http://logging.apache.org/log4net/release/sdk/log4net.Core.LevelConstructor1.html
they do not even explain what this int level
means, where can I find mapping for it? They just say that "higher values represent more severe levels" which is not enough.
I expected to have something like that:
appender.Threshold = new Level(level);
here level
might be of string or int type
Upvotes: 0
Views: 495
Reputation: 124696
The Level
class has public static members for predefined levels such as Off, Error, Warning:
You probably want to set the Threshold
property to one of these predefined levels, e.g.:
myAppender.Threshold = Level.Warn;
Alternatively, as described in the documentation, you can set the level to one of the entries in a repository's LevelMap.
UPDATE
Do you mean I have to work it out from their order? like Off maps to 0 (or 1?),
Not at all: Off maps to Level.Off.Value
; and similarly for the others.
Upvotes: 1