2017-01-10 67 views
0

我試圖使用NLog和NLog.Targets.Syslog登錄到papertrail系統,並以某種方式NLog無法從NLog.config加載目標時,我打電話NLog與NLog.Targets.Syslog - 對象引用錯誤

Logger logger = LogManager.GetCurrentClassLogger(); 

並拋出異常 未將對象引用設置爲對象的實例。

at NLog.Targets.Syslog.Settings.Rfc3164Config..ctor() 
    at NLog.Targets.Syslog.Settings.MessageBuilderConfig..ctor() 
    at NLog.Targets.Syslog.SyslogTarget..ctor() 

堆棧跟蹤

at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors) 
    at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, Boolean ignoreErrors, LogFactory logFactory) 
    at NLog.LogFactory.LoadLoggingConfiguration(String configFile) 
    at NLog.LogFactory.get_Configuration() 
    at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey) 
    at NLog.LogFactory.GetLogger(String name) 
    at NLog.LogManager.GetCurrentClassLogger() 
    at NLogPaperTrail.Controllers.HomeController.Index() in I:\Temp\Proj\tempsolution\NLogPaperTrail\NLogPaperTrail\Controllers 

這是NLog.config

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true"  ThrowExceptions = "true" > 

<extensions> 

     <add assembly="NLog.Targets.Syslog" /> 
    </extensions> 

    <targets> 
     <target name="syslog" xsi:type="Syslog" syslogserver="host.papertrailapp.com" port="5677" facility="Local7"/> 

    </targets> 

    <rules> 

    <logger name="*" minLevel="Trace" appendTo="syslog"/> 
    </rules> 
</nlog> 

誰能幫助或提供您的建議?

回答