bootstrap easyui RunJS JSFiddle codepen Gist

log4net配置的两种方式

----------文件配置:-------------------

<?xml version="1.0" encoding="utf-8" ?>
<log4net debug="true">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="Logs\\Log4Net.txt"/>
<appendToFile value="true" />
<!--记录日志写入文件时,不锁定文本文件,防止多线程时不能写Log,官方说线程非安全-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="200K" />
<!--<Encoding value="UTF-8" />-->
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="【%-5p %d】[%t] %c [%x] - %m%n " />
<!--<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />-->
</layout>
</appender>
<logger name="File">
<level value="All" />
</logger>
<root>
<level value="All" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>

----数据库 配置-----

<?xml version="1.0" encoding="utf-8"?>
<log4net debug="true">
<!--<root>
<level value="ALL" />
<appender-ref ref="ADONetAppender" />
</root>-->
<!--定义loger的名称和使用的appender-->
<logger name="EFLog4NetToDb">
<level value="ALL"/>
<appender-ref ref="ADONetAppender" />
</logger>
<appender name="ADONetAppender" type="log4net.Appender.AdoNetAppender,log4net">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="Data Source=192.168.8.236\csk;Initial Catalog=New_FGClinicalpathway;Persist Security Info=True;User ID=fg;Password=3602001"></connectionString>

<commandText value="INSERT INTO 系统_日志记录表([操作时间],[帐号],[日志类型],[IP地址],[请求路径],[日志内容])
VALUES (@Date, @UserName, @Logger, @ClientIP,@RequestUrl,@Exception)" />
<parameter>
<parameterName value="@Date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@UserName" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{UserName}" />
</layout>
</parameter>
<parameter>
<parameterName value="@Logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="@Logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@ClientIP" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{ClientIP}" />
</layout>
</parameter>
<parameter>
<parameterName value="@RequestUrl" />
<dbType value="String" />
<size value="500" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{RequestPath}" />
</layout>
</parameter>
<parameter>
<parameterName value="@Exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>

</appender>

</log4net>

 

posted @ 2014-04-08 16:31  lvyafei  阅读(247)  评论(0编辑  收藏  举报
博客地址:lvyafei 返回顶部   返回顶部   返回顶部 站长QQ,点击这里给我发消息
无觅关联推荐,快速提升流量