以下配置了二种写文件,第一种根据日期写文件yyyyMMdd.txt,第二种是写固定文件login.txt。
1, 下载Log4net组件:http://logging.apache.org/log4net/download.html
2,将log4net.dll加到项目引用中;
3,在app.config中添加相关配置信息,文件内容如下:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ChinaBank.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net-net-1.0"/>
</configSections>
<log4net>
<logger name="Daily.Logging">
<level value="INFO"/>
<appender-ref ref="DailyAppender" />
</logger>
<logger name="Login.Logging">
<level value="INFO"/>
<appe