NLog doen't work on IIS

走远了吗. 提交于 2019-11-30 06:04:09

问题


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>

and then just log something.

var logger = LogManager.GetCurrentClassLogger();
logger.Info("xxxx");

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


回答1:


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




回答2:


Edit website permissions in IIS and under security tab give IIS_IUSRS group full privileges. In Application, Pools find the pool your application is using and set some specific user.



来源:https://stackoverflow.com/questions/8850160/nlog-doent-work-on-iis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!