Archived

This forum has been archived. Please start a new discussion on GitHub.

NLog not working correctly

I created a service and run it under IceBox, use NLog for logging.

When I call the Debug, it does not show.
If I call Console.WriteLine - the messages are seen.
What am I doing wrong?
How to configure logging to be able to use NLog?

NLog.config:
<?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">

  <!-- 
  See http://nlog-project.org/wiki/Configuration_file 
  for information on customizing logging rules and outputs.
   -->
  <targets>
    <!-- add your targets here -->
    <target xsi:type="Console" name="c" layout="${longdate} ${uppercase:${level}} ${callsite:className=true:includeSourcePath=false:methodName=true}:: ${message}"/>

    <!--
    <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
    -->

  </targets>

  <rules>
    <!-- add your logging rules here -->
    <logger name="*" minlevel="Debug" writeTo="c" />

    <!--
    <logger name="*" minlevel="Trace" writeTo="f" />
    -->
  </rules>
</nlog>

Comments

  • NLog.config not found

    I'm resolved this problem.
    By default, NLog looks for a config file near executing file and not found it because executing file is iceboxnet.exe, but my assembly in another path.
  • bernard
    bernard Jupiter, FL
    Hi Dmitriy,

    I am glad you were able to figure this out, and thank you for posting the answer.

    Best regards,
    Bernard