首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NLog日志不记录

问NLog日志不记录
EN

Stack Overflow用户
提问于 2020-03-24 23:17:47
回答 1查看 43关注 0票数 1

我是NLog的新手,我正尝试在我正在编写的一个新应用程序中使用它。

下面是我的NLog配置。

当在VS中调试时,我得到了我期望的日志,但是当我在VS之外构建和运行程序时,我看不到任何日志。

有什么想法可以解释原因吗?

代码语言:javascript
复制
<?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"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="true"
      internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">

  <!-- optional, add some variables
  https://github.com/nlog/NLog/wiki/Configuration-file#variables
  -->
  <variable name="myvar" value="myvalue"/>

  <!--
  See https://github.com/nlog/nlog/wiki/Configuration-file
  for information on customizing logging rules and outputs.
   -->
  <targets>

    <!--
    add your targets here
    See https://github.com/nlog/NLog/wiki/Targets for possible targets.
    See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
    -->

    <!--Write events to a file with the date in the filename.-->
    <target xsi:type="ColoredConsole" name="ColoredConsole" useDefaultRowHighlightingRules="true"
            layout="${message}" />

    <target xsi:type="File" name="ConsilioDeployTool_CLI_ErrorLog" fileName="${basedir}/logs/ConsilioDeployTool_CLI_ErrorLog_${shortdate}.log">
      <layout xsi:type="CsvLayout" delimiter="Pipe" withHeader="true">
        <column name="level" layout="${level:upperCase=true}"/>
        <column name="callsite" layout="${callsite:includeSourcePath=true}" />
        <column name="stacktrace" layout="${stacktrace:topFrames=10}" />
        <column name="exception" layout="${exception:format=ToString}"/>
        <column name="logger" layout="${logger:shortName=false}"/>
        <column name="message" layout="${message}" />
      </layout>
    </target>

  </targets>

  <rules>
    <!-- add your logging rules here -->

    <!-- Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace)  to "f" -->
    <logger name="*" level="Info" writeTo="ColoredConsole" />
    <!--<logger name="*" level="Error" writeTo="ConsilioDeployTool_CLI_ErrorLog" />-->
    <logger name="*" level="Error" writeTo="ConsilioDeployTool_CLI_ErrorLog" />

  </rules>
</nlog>
EN

回答 1

Stack Overflow用户

发布于 2020-03-25 01:39:33

确保用户IIS_IUSRS对站点文件夹具有写入权限

您可以通过执行以下操作来分配写权限:

在windows资源管理器中,右键单击站点文件夹并在Edit...

  • under安全组选项卡上选择Properties

  • click,然后单击Edit...

  • under组或用户名:E217IIS_IUSRS

  • Under >,选择IIS_IUSRS

  • Under E122IIS_IUSRS权限E223,单击写入复选框以允许用户写入站点文件夹H224H125单击E126应用E227然后单击E128确定再次关闭属性窗口H232F233

我希望这对你有帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60833924

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档