【发布时间】:2011-11-14 07:52:26
【问题描述】:
我正在使用新的 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!");
}
}
我没有例外!
我在这里做错了吗? 我错过了什么。
PS
我已将 NLog.config 设置为“始终复制”,所以也不是这样。
【问题讨论】:
-
我已经在本地对其进行了测试,它适用于我的配置文件和代码。您能给我们提供一个发生这种情况的示例项目吗?
-
我不得不重新启动 Visual Studio 和办公室的计算机,它突然开始工作。我没有想到这是需要的!无论如何对不起...