微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误日志包含 Release Candidates 中的源代码路径

如何解决错误日志包含 Release Candidates 中的源代码路径

我在 Windows 服务中使用 nlog 作为日志提供程序。我正在使用具有以下设置的 Visual Studio 2019 发布应用程序。

enter image description here

这里,nlog 配置

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

在生产版本构建中,它在错误日志堆栈跟踪中显示构建 PC 的代码行路径,如下所示。

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

有什么办法可以从错误日志中忽略上述信息?我是否缺少 nlog 中的任何配置?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。