繁体   English   中英

为什么我的NLog配置无法在我的服务器上运行?

[英]Why is my NLog configuration not working on my server machine?

我正在使用ServiceStack框架和NLog进行日志记录。 我可以很好地登录我的本地机器。 但是在服务器上,它没有。 我检查过Nlog.config是否在bin目录中,整个目录,包括bin目录上面的目录都有写访问权限。

下面是配置文件的片段:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets async="true">
        <target xsi:type="File" name="file" fileName="${basedir}\logs\${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
        <target xsi:type="Debugger" name="debug"
            header="===== ${date:format=ddd, dd MMM yyyy} ${time} ====="
            layout="${level} | ${logger} | ${message} | ${onexception:${exception:format=tostring} | ${stacktrace}}"
            footer="===== end of session ===== ${newline}"
        />
    </targets>
    <rules>
        <logger name="*" minlevel="Trace" writeTo="file,debug" />    
    </rules>
</nlog>

可能是什么问题?

你有没有试过改变你知道的东西?

而不是fileName="${basedir}\\logs\\${shortdate}.log"而不是像fileName="c:\\logs\\${shortdate}.log"

Web应用程序中NLog的basedir变量不在bin文件夹中运行。 我想你会在里面找到日志文件

%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files

如果它是一个ASP.NET应用程序。

虽然我不知道您的服务器环境和配置有什么问题但我总是发现检查以下内容很有帮助:

  1. 确保您确切知道日志的目录是什么(由@PauloCorreia建议)。
  2. 确保该目录确实存在。
  3. 确保IIS工作进程具有能够写入该目录的正确权限。

FWIW,根据我的经验,它通常是一个权限问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM