0
以下是包含簡單日誌文件目標的簡單nlog配置。我的問題是如何添加Nlog.Targets.Redis的目標?Nlog.Targets.Redis:如何將NLog配置爲redis目標?
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" />
</targets>
以下是包含簡單日誌文件目標的簡單nlog配置。我的問題是如何添加Nlog.Targets.Redis的目標?Nlog.Targets.Redis:如何將NLog配置爲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>