0

I'm using nlog as the log provider in my windows service. I'm publishing the application using Visual Studio 2019 with following settings.

enter image description here

here, nlog configurations

<?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"
      autoReload="true"
      internalLogLevel="Info"
      internalLogFile="c:\temp\internal-nlog.txt">

  <!-- enable asp.net core layout renderers -->
  <extensions>
    <add assembly="NLog.Web.AspNetCore" />
  </extensions>

  <!-- the targets to write to -->
  <targets>
    <!-- Log in a separate thread, possibly queueing up to
        5000 messages. When the queue overflows, discard any
        extra messages-->
    <target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
      <target xsi:type="File" name="files" fileName="${basedir}/logs/log.current.log"
              layout="${longdate}|${callsite}|${level}|${message}|${exception:format=Message,StackTrace}|${stacktrace}"
              archiveFileName="${basedir}/logs/archives/log.${date:format=yyyy-MM-dd}.{#}.log "
              archiveAboveSize="104857600" archiveNumbering="Rolling" maxArchiveFiles="20" concurrentWrites="true"
              keepFileOpen="false" />
    </target>
    <target name="console" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
      <target name="inner_console" xsi:type="ColoredConsole"
              layout="${level} [${threadid}] ${logger} ${message} ${exception:format=Message,StackTrace}">
        <highlight-row condition="Level==LogLevel.Fatal" foregroundColor="Red" />
        <highlight-row condition="Level==LogLevel.Error" foregroundColor="Red" />
        <highlight-row condition="Level==LogLevel.Warn" foregroundColor="Yellow" />
        <highlight-row condition="Level==LogLevel.Info" foregroundColor="DarkCyan" />
        <highlight-row condition="Level==LogLevel.Debug" foregroundColor="DarkGreen" />
      </target>
    </target>
  </targets>

  <!-- rules to map from logger name to target -->
  <rules>
    <!--Skip non-critical Microsoft logs and so log only own logs-->
    <logger name="Microsoft.*" maxLevel="Info" final="true" />
    <logger name="*" minlevel="Info" writeTo="file,console" />
  </rules>
</nlog>

In production release build, it shows the code line path of the build PC in error log stack trace as below.

in D:\SourceCode\Service\src\BulkProcessAgent.cs:line 74

Is there any way to omit above information from error logs? Am I missing any configurations in nlog?

Suzuna Minami
  • 391
  • 2
  • 11
Aruna
  • 1,962
  • 4
  • 25
  • 50

0 Answers0