日期:2014-05-17  浏览次数:20437 次

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">
            <leve