我第一次使用log4net,並使用提供的配置示例遵循了文檔,但是調試語句不記錄。log4net不記錄調試語句
信息,錯誤,警告和致命等級都記錄正確。任何人都可以告訴我我錯過了什麼嗎?
的app.config:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<log4net>
<appender name="Console" type="log4net.Appender.ColoredConsoleAppender">
<mapping>
<level value="INFO" />
<foreColor value="Green"/>
</mapping>
<mapping>
<level value="DEBUG" />
<foreColor value="Cyan,HighIntensity"/>
</mapping>
<mapping>
<level value="WARN" />
<foreColor value="Purple,HighIntensity"/>
</mapping>
<mapping>
<level value="ERROR" />
<foreColor value="Red,HighIntensity"/>
</mapping>
<mapping>
<level value="FATAL" />
<foreColor value="Yellow,HighIntensity"/>
</mapping>
<layout type="log4net.Layout.PatternLayout">
<!-- Pattern to output the caller's file name and line number -->
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="example.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="Console" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
有人提到檢查集信息爲[組件:log4net.Config.XmlConfigurator()],但是存在具有或不具有該行沒有區別。
記錄儀可以聲明如下:
private static readonly ILog log = LogManager.GetLogger(typeof(CWD_Netsuite));
,並像訪問:
XmlConfigurator.Configure();
log.Debug("Debugging"); //does not get logged
log.Info("Entering Application"); //logged to console and log file
log.Debug("Debug Statement"); //does not get logged
log.Error("Error statement"); //logged to console and log file
log.Warn("Warning statement"); //logged to console and log file
log.Fatal("Fatal Statement"); //logged to console and log file
只是爲了澄清以下所有答案,在log4net的記錄層級,DEBUG是最低的,低於信息。 –