Log4Net主页 http://logging.apache.org/log4net/index.html
Log4Net KPI http://logging.apache.org/log4net/release/sdk/
1、 信息记录到Access中
<appender name="ADONetAppender_Access" type="log4net.Appender.ADONetAppender">
<bufferSize value="0"/>
<connectionString value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Logs.mdb;Password=Jason" />
//Data Source在这里必须写绝对地址;Password是数据库的访问密码;user没有写,默认是admin
<commandText value="INSERT INTO [Logs]([Message]) VALUES (@message)" />
<!---信息-->
<parameter>…</parameter>
</appender>
2、 信息记录到文件
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" type="txt" value="Error/" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="maxSizeRollBackups" value="10" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<param name="DatePattern" value="yyyyMMdd'.txt'" />
<param name="StaticLogFileName" value="false" />
<Encoding value="UTF-8" />
<layout type="ZHDMTSys.Log.ExpandLayout2.ReflectionLayout,ZHDMTSys.Log">
<!--<param name="Header" value="&#13;&#10;" /><param name="Footer" value="%newline" />-->
<param name="ConversionPattern"
value="记录时间:%date 操作者ID:%property{UserName} 浏览器:%property{Browser} 操作系统:%property{MachineName}%n消息描述:%property{Message}%n 异常:%exception %n ------------------------------------------------------------------------------%n" />
</layout>
</appender>
属性列表
备注:Log4net的配置信息中,属性可以有两种写法,比如<param name="AppendToFile" value="true" />
相当于<AppendToFile value="true" />