我将log4net用于Asp.Net MVC,并且希望在根级别设置为“全部”时支持输出日志。
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!-- Define output appenders -->
<appender name="PageLoading_RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="App_Data\\Logs\\PageLoading.log" />
<appendToFile value="true" />
<rollingStyle value="Once" /> <!-- new log file on restart -->
<maxSizeRollBackups value="10"/> <!-- renames rolled files on startup 1-10, no more than 10 -->
<maximumFileSize value="204800KB" />
<datePattern value="yyyyMMdd" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="[START LOG] " />
<param name="Footer" value="[END LOG] " />
<conversionPattern value="%d %-5level - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="ALL" />
<appender-ref ref="PageLoading_RollingLogFileAppender" />
</root>
</log4net>
我希望只有在将Web配置Log4Net设置为“所有”级别时,日志记录才是日志记录,但是实际输出是logger.Debug。