NLog在IIS上不起作用 [英] NLog doen't work on IIS

查看:309
本文介绍了NLog在IIS上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将NLog添加到我的项目中.按照说明创建NLog.config.

I added NLog to my project. Following the instructions I created 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时,不会创建任何日志.

With the developer web server it work fine, but when I publish the app to IIS, no logs are created.

推荐答案

NLog.config是否将复制到输出目录"属性设置为总是复制"?

Does NLog.config have the property "Copy to Output Directory" set as "Copy always"?

这篇关于NLog在IIS上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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