当前位置: 代码迷 >> ASP.NET >> log4net sql2005,该怎么处理
  详细解决方案

log4net sql2005,该怎么处理

热度:7963   发布时间:2013-02-25 00:00:00.0
log4net sql2005
我用log4net往数据库写日志。配置
C# code
<appender name="ADONetAppender" type="log4net.Appender.ADONetAppender">            <bufferSize value="1" />               <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>               <connectionString value="Password=123;Persist Security Info=False;User ID=sa;Initial Catalog=Purview;Data Source=LX-PC"/>            <commandText value="INSERT INTO ErrorLog ([dtDate],[sThread],[sLevel],[sLogger],[sMessage],[sException]) VALUES (@log_date, @thread, @log_level, @logger,@message, @exception)" />            <parameter>                <parameterName value="@log_date" />                <dbType value="DateTime" />                <layout type="log4net.Layout.RawTimeStampLayout" />            </parameter>            <parameter>                <parameterName value="@thread" />                <dbType value="String" />                <size value="100" />                <layout type="log4net.Layout.PatternLayout">                    <conversionPattern value="%t" />                </layout>            </parameter>            <parameter>                <parameterName value="@log_level" />                <dbType value="String" />                <size value="200" />                <layout type="log4net.Layout.PatternLayout">                    <conversionPattern value="%p" />                </layout>            </parameter>            <parameter>                <parameterName value="@logger" />                <dbType value="String" />                <size value="500" />                <layout type="log4net.Layout.PatternLayout">                    <conversionPattern value="%logger" />                </layout>            </parameter>            <parameter>                <parameterName value="@message" />                <dbType value="String" />                <size value="3000" />                <layout type="log4net.Layout.PatternLayout">                    <conversionPattern value="%m" />                </layout>            </parameter>            <parameter>                <parameterName value="@exception" />                <dbType value="String" />                <size value="4000" />                <layout type="log4net.Layout.ExceptionLayout" />            </parameter>        </appender>        <root>            <level value="WARN"/>            <level value="INFO"/>            <level value="DEBUG"/>            <level value="FINE"/>            <appender-ref ref="ADONetAppender" />        </root>        <logger name="iNotes">            <level value="WARN"/>            <level value="INFO"/>            <level value="DEBUG"/>            <level value="FINE"/>            <appender-ref ref="ADONetAppender"/>        </logger>        <logger name="StellaLogger">            <level value="ALL"/>            <appender-ref ref="AdoNetAppender" />        </logger>

网页代码
C# code
        private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  相关解决方案