NLOG不是在释放模式工作 [英] Nlog not working in release mode

查看:304
本文介绍了NLOG不是在释放模式工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NLOG登录我的asp.net mvc的例外(C#)应用程序。

I am using Nlog to log the exceptions in my asp.net mvc (C#) application.

NLOG不是在释放模式下工作。同样是在调试模式下运行时的工作。

Nlog is not working in release mode. The same is working when running in debug mode.

可能是什么问题?是否有修复此?

What may be the problem? Is there any fix for this?

推荐答案

我有同样的问题,因为你:

I was having the same problem as you:


  • ASP.NET MVC 3

  • .NET 4

  • IIS 7

  • 释放模式

我试图改变目录,并更改权限无济于事。我甚至尝试使内部记录,但即使没有工作!没有失败,没有例外,没有!

I tried changing directories, and changing permissions to no avail. I even tried enabling the internal logging but even that didn't work! No failures, no exceptions, nothing!

多做一些调查后,我找到了解决办法。 由于某种原因,NLOG没有加载配置文件在所有。我意识到这一点后,我编程启用了内部记录。内部日志报这个:

After doing some more investigating, I found the solution. For some reason, NLog wasn't loading the config file AT ALL. I realized this after I programmatically enabled the internal logging. The internal logging reported this:

2012-02-13 11:34:40.3181 Debug Targets for MyMvcController by level:
2012-02-13 11:34:40.3181 Debug Trace =>
2012-02-13 11:34:40.3181 Debug Debug =>
2012-02-13 11:34:40.3181 Debug Info =>
2012-02-13 11:34:40.3181 Debug Warn =>
2012-02-13 11:34:40.3181 Debug Error =>
2012-02-13 11:34:40.3181 Debug Fatal =>

这基本上是说,没有任何日志级别的定义的目标!绝对不正确!

This was basically saying that there were no targets defined for any of the log levels! Definitely not correct!

我NLOG配置文件,是因为它可以作为简单的(它设置为复制到输出目录):

My NLog configuration file was as simple as it could be(and it was set to Copy to Output Directory):

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwExceptions="true">
  <targets>
    <target name="file" xsi:type="File" fileName="${basedir}/MyApplication.log" />
  </targets>
  <rules>
    <logger name="*" minlevel="Trace" writeTo="file" />
  </rules>
</nlog>

我仍然不知道确切的为什么这是怎么回事,但移动NLOG配置到web.config中直接解决了这个问题。

I'm still not sure exactly why this was happening, but moving the NLog configuration into the web.config directly resolved the problem.

这篇关于NLOG不是在释放模式工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆