开发者

Hidden gems of Log4Net?

I'm curious if anyone开发者_StackOverflow has familiarity with Log4Net (particularly the c# library) can share what they think are the most useful features that someone new to the library might overlook or misunderstand.


A very important feature for me are context properties (global or per thread). This allows me to attach arbitrary information to log messages (e.g. an order number so you can track a specific order as it is processed by various systems).


There are more levels than the ones exposed by the helper methods (ILog.Debug, ILog.Fatal, etc) of the ILog interface. For log4net version 1.2.10.0 you have the following levels and associated cut off values used to filter messages in the loggers configuration:

OFF: 2147483647
EMERGENCY: 120000
FATAL: 110000
ALERT: 100000
CRITICAL: 90000
SEVERE: 80000
ERROR: 70000
WARN: 60000
NOTICE: 50000
INFO: 40000
DEBUG: 30000
FINE: 30000
TRACE: 20000
FINER: 20000
VERBOSE: 10000
FINEST: 10000
ALL: -2147483648

They can be used like in the following snippet where Log is of type ILog:

Log.Logger.Log(null, log4net.Core.Level.Emergency, "Help!", null);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜