在开发环境中,将创建所有日志,其中包括INFO和DEBUG日志,但是当我们将其部署到IIS时,只会创建INFO日志,而不会创建DEBUG日志。
我尝试过通过将优先级值也更改为INFO以及DEBUG进行尝试,目前它是ALL,但是DEBUG日志没有成功
请协助。
文件:Web.config
<log4net debug="true">
<appender name="RollingFileAppenderSize" type="log4net.Appender.RollingFileAppender">
<param name="file" value="C:\\Temp\\BSRollingFileAppenderSize.log" />
<param name="appendToFile" value="true" />
<param name="rollingStyle" value="Size" />
<param name="maxSizeRollBackups" value="10" />
<param name="maximumFileSize" value="10MB" />
<param name="staticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%M] - %m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="ALL"/>
</filter>
</appender>
<appender name="SessionsAppender" type="log4net.Appender.RollingFileAppender">
<param name="file" value="C:\\Temp\\BSSessions.log" />
<param name="appendToFile" value="true" />
<param name="rollingStyle" value="Size" />
<param name="maxSizeRollBackups" value="10" />
<param name="maximumFileSize" value="10MB" />
<param name="staticLogFileName" value="true" />
<layout type="Framework.Common.Logging.CsvPatternLayout, Framework.Common">
<header value="DateTime,Level,Type,Action,Message " />
<conversionPattern value="%date{M/d/yyyy H:mm:ss.fff}%newfield%level%newfield%type%newfield%property{Action}%newfield%message%endrow" />
</layout>
</appender>
<root>
<!-- ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<level value="ALL" />
<appender-ref ref="RollingFileAppenderSize" />
</root>
<logger name="Framework.Common.Commands.Handlers.Sessions">
<level value="INFO" />
<appender-ref ref="SessionsAppender" />
</logger>
</log4net>
答案 0 :(得分:0)
您应该将级别设置为“调试”:
<log4net debug="true">
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFileAppenderSize"/>
</root>
</log4net>
答案 1 :(得分:0)
我将为您提供完整的配置示例,以便您可以根据自己的情况进行调整。 LevelMin to ALL
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file value="folder\logfile.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<MaxSizeRollBackups value="20" />
<MaximumFileSize value="40MB" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss:fff} [%thread] %-5level %logger{1} - %message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="ALL"/>
</filter>
<staticLogFileName value="true" />
</appender>
<root>
<appender-ref ref="FileAppender" />
</root>
</log4net>