标签:
1、百度一下log4dll下载 2、webconfig 里的<configSetions>节点中添加 <section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> 3、增加节点内容如下: <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="Log//" /> <param name="AppendToFile" value="true" /> <param name="MaxSizeRollBackups" value="10" /> <param name="StaticLogFileName" value="false" /> <param name="DatePattern" value="yyyy-MM-dd".log"" /> <param name="RollingStyle" value="Date" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d 系统异常: %m%n%n" /> </layout> </appender> <root> <level value="All" /> <appender-ref ref="LogFileAppender" /> </root> </log4net> 4、在引用log4类库、项目中里的AssemblyInfo类中添加日志监视 [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)] 5、测试日志代码 ILog log = log4net.LogManager.GetLogger("LogFileAppender"); log.Error(ex);
标签:
原文地址:http://www.cnblogs.com/wangjx/p/4799378.html