我正在尝试使用NLog和NLog.Targets.Syslog登录papertrail系统,并且当我调用时,NLog无法从NLog.config加载目标
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>
任何人都可以提供帮助或提供您的建议吗?
答案 0 :(得分:1)