<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!--定义输出到文件中-->
<appender name="uFile" type="log4net.Appender.RollingFileAppender">
<!--定义文件存放位置-->
<file value="log\" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd'.txt'" />
<staticLogFileName value="false" />
<param name="MaxSizeRollBackups" value="100" />
<layout type="log4net.Layout.PatternLayout">
<!--每条日志末尾的文字说明-->
<!--输出格式-->
<!--样例:2008-03-26 13:42:32,111 [10] INFO Log4NetDemo.MainClass [(null)] - info-->
<conversionPattern value="%newline %ndatetime:%date threadID:[%thread] level: %-5level class:%logger property: [%property{NDC}] - %n%message%newline %n" />
</layout>
</appender>
<root>
<level value="ALL" />
<!--文件形式记录日志-->
<appender-ref ref="uFile" />
</root>
</log4net>
private ILog logger = LogManager.GetLogger(typeof(UClass));