2013-09-25 17 views

回答

0

以下是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>