Kawika Moss
Kawika Moss

Reputation: 23

NLog Logs not logging

I'm new to NLog and I'm attempting to use it in a new app I'm writing...

Below is my NLog config.

When debugging in VS I get the logs I expect, but when I build and run the program outside of VS I don't see any logs.

Any ideas as to why?

<?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>

Upvotes: 1

Views: 365

Answers (1)

kagundajm
kagundajm

Reputation: 1210

Make sure the user IIS_IUSRS has write permissions on the site folder

You can assign write permission by doing the followin:

  • In windows explorer right click on the site folder
  • select Properties
  • click on the Security tab
  • Click on Edit...
  • under Group or user names:, select IIS_IUSRS
  • Under Permissions for IIS_IUSRS, click on Write checkbox to allow the user write to the site folder
  • Click Apply and then OK and OK again to close the Properties window

I hope that helps

Upvotes: 1

Related Questions