.Net配置log4net
使用log4net-1.2.0-beta8在项目的AssemblyInfo.cs文件中设置
[assembly: log4net.Config.DOMConfiguratorAttribute(Watch=true)]
添加并编辑项目配置文件(默认为App.config),内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="stdout" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<!--conversionPattern value="[%d %l] %n%m%n" /-->
<param name="ConversionPattern" value="[%d %l] %m%n" />
</layout>
</appender>
<appender name="file" type="log4net.Appender.FileAppender">
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d %l] %m%n" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="stdout" />
<appender-ref ref="file" />
</root>
<logger name="*">
<level value="ALL" />
补充:asp.net教程,基础入门