gpt4 book ai didi

configuration - Nlog.Targets.Redis : How to configure NLog for redis target?

转载 作者:可可西里 更新时间:2023-11-01 11:43:37 28 4
gpt4 key购买 nike

以下是包含简单日志文件目标的简单 nlog 配置。我的问题是如何为 Nlog.Targets.Redis 添加目标?

<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>

最佳答案

以下是 NLog.Targets.Redis 的正确配置。如果您使用 nuget 获取包,请注意 nuget 安装了错误的 NLog 版本,因此您应该像下面这样放置 dependentAssembly 部分。

<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<runtime>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="en-us" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="2.0.1.2" />
</dependentAssembly>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
<extensions>
<add assembly="NLog.Targets.Redis" />
</extensions>
<targets>
<target name="redis" type="Redis" host="192.168.56.2" key="logstash" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="redis" />
</rules>
</nlog>
</configuration>

关于configuration - Nlog.Targets.Redis : How to configure NLog for redis target?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19005519/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com