我有以下代碼:爲什麼IsDebugEnabled在我的代碼中總是爲True?
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
XmlConfigurator.Configure(new FileInfo("log4net.config"));
問題是下面總是語句返回True
if (Log.IsDebugEnabled) { /* do time consuming stuff and log the result */
這是我的log4net的配置_文件
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="ERROR" />
<param name="LevelMax" value="ERROR" />
</filter>
<param name="File" value="Log.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%5p [%d] - %m%n" />
</layout>
</appender>
<root>
<appender-ref ref="LogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
爲什麼IsDebugEnabled總是返回True?
你看過這個問題嗎(http://stackoverflow.com/questions/220021/how-do-i-configure-log4net-so-that-log-isdebugenabled-is-true)。接受的答案看起來對你有用 – 2011-04-08 11:58:16
IsDebugEnabled設置在哪裏? – 2011-04-08 11:58:21
@RB我已經調用XmlConfigurator.Configure。 – 2011-04-08 12:06:04