如何在Log4Net中创建自定义级别,例如' ERROR ',' WARN ',' INFO '。例如。我想创建一个级别' General ',我想将其用作
logger.General("This is general log");
答案 0 :(得分:6)
我找到了解决方案。
private static readonly log4net.Core.Level GeneralLevel= new log4net.Core.Level(50000,"General");
log4net.Util.LogLog.InternalDebugging=true;
log4net.LogManager.GetRepository().LevelMap.Add(GeneralLevel);
General("This is Custom Log");
public void General(string message)
{
Log.Logger.log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,GeneralLevel,message,null);
}