我将 NLog 添加到我的项目中。按照说明我创建了 NLog.config。
<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}"
fileName="${basedir}/${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
</rules>
</nlog>
然后只是记录一些东西。
var logger = LogManager.GetCurrentClassLogger();
logger.Info("xxxx");
使用开发人员 Web 服务器它可以正常工作,但是当我将应用程序发布到 IIS 时,不会创建任何日志。
最佳答案
NLog.config 是否将属性“复制到输出目录”设置为“始终复制”?
关于asp.net-mvc - NLog 在 IIS 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8850160/