我已将NLog添加到我的项目中,并且在开发环境中,它运行正常.
我创建了一个安装文件来部署我的应用程序.NLog.config文件未在安装项目中显示为依赖项.因此,我将其添加为文件,并在部署时与exe文件和App.config存在于同一目录中.
它不做任何记录.我不知道为什么.这是配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<?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">
<variable name="day" value="${date:format=dd}" />
<variable name="month" value="${date:format=MM}" />
<variable name="year" value="${date:format=yyyy}" />
<variable name="verbose" value="${longdate} | ${level} | ${message} | ${exception:format=tostring,message,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method}}" />
<targets>
<target name="logfile" xsi:type="File" fileName="${basedir}/Logs/${year}${month}${day}.log" layout="${verbose}" />
</targets>
<rules>
<logger name="*" minlevel="Error" writeTo="logfile" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒.干杯!