比较好的Log4Net配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    </configSections>
    <log4net>
        <root>
            <level value="ALL" />
            <appender-ref ref="Log" />
            <appender-ref ref="ConsoleAppender" />
        </root>
        <logger name="ErrorLogger">
            <level value="ERROR" />
            <appender-ref ref="ErrorLog" />
        </logger>
        <appender name="ConsoleAppender" type=" log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger [%ndc] &lt;%property{auth}&gt; - %message%newline" />
            </layout>
        </appender>
        <appender  name="Log" type="log4net.Appender.RollingFileAppender,log4net" >
            <param name="File" value=".\log\log_" />
            <param name="AppendToFile" value="false" />
            <param name="RollingStyle" value="Date" />
            <param name="DatePattern" value="yyyyMMdd'.log'" />
            <param name="StaticLogFileName" value="false" />
            <layout type="log4net.Layout.PatternLayout,log4net">
                <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
                <param name="Header" value="&#13;&#10;----------------------header--------------------------&#13;&#10;" />
                <param name="Footer" value="&#13;&#10;----------------------footer--------------------------&#13;&#10;" />
            </layout>
        </appender>
        <appender  name="ErrorLog" type="log4net.Appender.RollingFileAppender,log4net" >
            <param name="File" value=".\errorLog\log_" />
            <param name="AppendToFile" value="false" />
            <param name="RollingStyle" value="Date" />
            <param name="DatePattern" value="yyyyMMdd'.log'" />
            <param name="StaticLogFileName" value="false" />
            <layout type="log4net.Layout.PatternLayout,log4net">
                <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
                <param name="Header" value="&#13;&#10;----------------------header--------------------------&#13;&#10;" />
                <param name="Footer" value="&#13;&#10;----------------------footer--------------------------&#13;&#10;" />
            </layout>
        </appender>
    </log4net>
</configuration>

你可能感兴趣的:(log)