给自己的项目加入日志功能,首先添加引用log4net.dll,再设置配置文件,由于是WebForm应用,所以配置文件是app.config,如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<appSettings>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender" >
<file value="D:\\NetDiskLogData\\" />
<appendToFile value="true" />
<datePattern value="yyyy-MM-dd.LOG" />
<maxSizeRollBackups value="10" />
<rollingStyle value="Date"