日誌管理

採用log4net+Common.Logging.Log4Netapp

一、Nuget:Common.Logging.Log4Net208 自動下載完四個包spa

二、配置config code

Common:blog

<sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>

<!--與log4net關聯-->
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net208">
<arg key="configType" value="FILE-WATCH" />
<arg key="configFile" value="~/Conf/log4net.config" />
<arg key="level" value="INFO" />
</factoryAdapter>
</logging>
</common>get

Log4net:log4net.configit

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

<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="my_log-file.txt"/>
<param name="AppendToFile" value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>io

</layout>class

</appender>擴展

<logger name="yateJob" additivity="false" >
<level value="ALL" />
<appender-ref ref="yateJobTxtAppender" />
</logger>
</log4net>
</configuration>配置

 

三、擴展

相關文章
相關標籤/搜索