我正在使用新的 NLog 2.0。 我已在 2 个不同的平台上手动设置并借助 NuGet 进行设置:
1) 在家使用 Visual Web Developer Express 2010。
2) 在办公室的 Visual Studio 2010 上。
在这两种情况下我都无法记录它。
我已阅读建议的所有选项here运气不好。
我正在使用第一个教程中的非常基本的配置。
<?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"
throwExceptions="true">
<targets>
<target name="logfile" xsi:type="File" fileName="${basedir}/file.txt" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile"/>
</rules>
</nlog>
这是我调用记录器的方式:
public partial class _Default : System.Web.UI.Page
{
Logger logger = LogManager.GetCurrentClassLogger();
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
logger.Fatal("Hello Log!");
}
}
我没有异常(exception)!
我在这里做错了什么吗? 我缺少什么。
附注
我已将 NLog.config 设置为“始终复制”,因此情况也并非如此。
最佳答案
我必须重新启动 Visual Studio,它突然开始工作。
我没想到这是必要的!
无论如何,抱歉......
关于asp.net - NLog 不记录日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8118695/