webconfig添加:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog40">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
</configuration>
外加 nlog配置:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true" throwExceptions="true"
internalLogLevel="Error" internalLogFile="c:\temp\nlog-internal.log">
<targets async="true">
<target xsi:type="File" encoding="UTF-8" name="TxtLog" fileName="${basedir}/ALogs/${shortdate}.log"
layout="[${pad:padding=5:inner=${level}}]${time}|${callsite}|${message}|${exception}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="TxtLog"></logger>
</rules>
</nlog>```
04-07
3069
