Log4Net

8279 단어 log
   http://logging.apache.org/log4net/



  web.config  <configuration><configSections>

  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

</configSections>

 <configuration>       log4net    :



<log4net debug="false">

    <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >

        <param name="File" value="../WebServiceErrLog.txt" />

        <param name="datePattern" value="yyyy-MM-dd HH:mm" />

        <param name="AppendToFile" value="true" />

        <layout type="log4net.Layout.PatternLayout">

            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />

        </layout>

    </appender>

    <appender name="HttpTraceAppender" type="log4net.Appender.ASPNetTraceAppender" >

        <layout type="log4net.Layout.PatternLayout">

            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />

        </layout>

    </appender>

    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >

        <layout type="log4net.Layout.PatternLayout">

            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />

        </layout>

    </appender>

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

        <param name="File" value="C:\Log.txt" />

        <param name="AppendToFile" value="true" />

        <param name="MaxSizeRollBackups" value="10" />

        <param name="MaximumFileSize" value="5MB" />

        <param name="RollingStyle" value="Size" />

        <param name="StaticLogFileName" value="true" />

        <layout type="log4net.Layout.PatternLayout">

            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />

        </layout>

    </appender>

    <root>

        <level value="DEBUG" />

        <appender-ref ref="LogFileAppender" />

    </root>

</log4net>

 Global.asax.cs Application_Start         :



log4net.Config.DOMConfigurator.Configure();

  :



log4net.ILog logger = log4net.LogManager.GetLogger(this.GetType());

logger.Info(info);

   :

log4net.Appender.AdoNetAppender <        access,sqlserver        >

log4net.Appender.FileAppender <            >

log4net.Appender.EventLogAppender <               >

log4net.Appender.RollingFileAppender <          ,         ,      >

좋은 웹페이지 즐겨찾기