c# - 使用 Nlog 将 VS 调试日志记录到 Redis 服务器
问题描述
我正在使用 NLog 将调试信息记录到 Redis 服务器。在服务器上运行良好。以下是 Nlog.Config 文件
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="false" autoReload="true">
<extensions>
<add assembly="App.Host" />
</extensions>
<targets>
<target xsi:type="LoggingContextWrapper" name="logstash">
<target xsi:type="AsyncWrapper">
<target xsi:type="Redis" host="hostname" key="logstash" dataType="list" port="6379" password="password">
<layout xsi:type="JsonLayout">
<attribute name="application" layout="testapplication"/>
<attribute name="environment" layout="develop"/>
<attribute name="time" layout="${longdate}"/>
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="appdomain" layout="${appdomain}"/>
<attribute name="asp-request" layout="${asp-request}"/>
<attribute name="logger" layout="${logger}"/>
<attribute name="machinename" layout="${machinename}"/>
<attribute name="basedir" layout="${basedir}"/>
<attribute name="message" layout="${message}"/>
<attribute name="type" layout="cornerstone"/>
<attribute name="@fields" layout="!fields"/>
<attribute name="@tags" layout="!tags"/>
<attribute name="@requestIds" layout="!requestIds"/>
</layout>
</target>
</target>
</target>
</targets>
<rules>
<logger name="Api" minlevel="Info" writeTo="logstash" final="true" />
</rules>
</nlog>
日志记录代码是这样的
Logger apiLogger = LogManager.GetLogger("Api");
apiLogger.Log(infoString);
现在我想在服务器上也有我的 VS 调试日志,所以我在 NLog.Config 文件中进行了以下更改
<logger name="Api" minlevel="Debug" writeTo="logstash" final="true" />
还将 C# 方法更改为
apiLogger.Debug(infoString);
但我无法在 Redis 服务器上看到调试日志详细信息。还有什么我需要做的吗?
解决方案
推荐阅读
- excel - 滚动两列并查看差异并删除重复项
- swift - 如何保持在本机中调用委托方法而不是对本机 Firebase 做出反应?
- bash - 如何计算 PDF 签名哈希?
- c# - 如何配置多个异常处理程序
- javascript - 加载窗口后需要绑定事件
- javascript - 在 React 中如何刷新页面并在刷新页面后打开新模式?
- scala - 使用 spark-cosmos-connector 过滤 cosmos db 中的行失败
- ionic3 - Intro.js 步骤在 ionic 3 的 iOS 设备中不显示
- python - 超时不适用于 Wait_For_Message Discord PY
- php - 尚未应用特征方法角色,因为与 App\User 上的其他特征方法存在冲突