这是我的 log4net 配置文件
<?xml version="1.0" encoding="utf-8" ?>
<log4net debug="true">
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true" />
<levelMin value="DEBUG" />
<levelMax value="FATAL" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %5rms [%-17.17t] %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<appender name="SmtpAppender" type="MySmtpClientSmtpAppender">
<to value="a@a.com" />
<from value="admin@x.com" />
<subject value="Game Server Monitoring Failed!" />
<smtpHost value="smtp.x.com" />
<username value="admin" />
<password value="x" />
<bufferSize value="256" />
<lossy value="true" />
<evaluator type="log4net.spi.LevelEvaluator">
<threshold value="ERROR" />
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d [ThreadId: %t] Class:%c{1} Method:%M %nMESSAGE:%n%m%n%n" />
</layout>
</appender>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Logs\\wwwlog" />
<appendToFile value="true" />
<datePattern value="yyyyMMdd" />
<maximumFileSize value="10MB" />
<!--<rollingStyle value="Date" />-->
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true" />
<levelMin value="INFO" />
<levelMax value="FATAL" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="MySmtpAppender" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
我错过了什么吗?有什么提示/建议可以减少日志大小,同时保持清晰、更好的转换模式?有什么有趣的小技巧吗?
编辑:XMl 文件没有进入代码块。更新。有什么建议吗?