.net-core - 错误日志包含候选版本中的源代码路径
问题描述
我在我的 Windows 服务中使用 nlog 作为日志提供程序。我正在使用具有以下设置的 Visual Studio 2019 发布应用程序。
这里,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 中的任何配置?
解决方案
推荐阅读
- python - 如何为我控制的 DateTime 编写睡眠功能?
- python - 在 macOS 上安装 rpy2 -- R_HOME 变量的问题
- python - 我正在尝试编写一个 discord.py 机器人来保存和命名图像 url,然后可以调用图像
- python - Django REST - 查询集 order_by 不能按降序工作
- python - 如何在 Python 重构期间防止变量名冲突?
- scala - 对数据框中的列(PANCARD)值进行排序
- c - 尝试在函数中使用 txt 文件时获取“'->' 的无效类型参数(有 'int')”
- html - 剪辑路径在 Safari 上无法正常工作
- windows - Windows批处理命令创建备份文件夹和替换文件夹
- tensorflow - 如何在 Keras/Tf 中实现两层的张量积