目前很多C#的類庫使用common Logging日志接口記錄日志,很多時候系統已經有了默認的日志記錄方式,這時候可以在配置文件將默認的方式集成進去.
factoryAdapter 大部分已經有提供,可使用NuGet 查找獲取.
<sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> </sectionGroup>
<common>
<logging>
<factoryAdapter type="Common.Logging.EntLib.EntLibLoggerFactoryAdapter, Common.Logging.EntLib60">
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="level" value="INFO" />
<arg key="dateTimeFormat" value="HH:mm:ss:fff" />
</factoryAdapter>
<!--<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="showLogName" value="true"/>
<arg key="showDataTime" value="true"/>
<arg key="level" value="INFO"/>
<arg key="dateTimeFormat" value="HH:mm:ss:fff"/>
</factoryAdapter>-->
</logging>
</common>
