【发布时间】:2013-06-05 23:54:15
【问题描述】:
我正在尝试将带有 Nlog 的日志写入 Eventlog,这是我的 Nlog.config 的一个示例
<target xsi:type="EventLog"
name="eventlog"
layout="${message}"
log="Application"
source="MyAppName" />
当使用管理员权限执行InstallNlogConfig 时,会显示此错误:
NLog.NLogConfigurationException:初始化时出错 EventLog Target[eventlog] - System.IO.IOException:网络路径 没找到。
zh Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode, 字符串 str) zh Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive hKey, String machineName, RegistryView view) en System.Diagnostics.EventLog.GetEventLogRegKey(字符串机,布尔值 可写) zh System.Diagnostics.EventLog.FindSourceRegistration(字符串源, String machineName, Boolean readOnly, Boolean wantToCreate) en System.Diagnostics.EventLog._InternalLogNameFromSourceName(字符串 源,字符串 machineName) zh System.Diagnostics.EventLog.LogNameFromSourceName(字符串源, String machineName) zh NLog.Targets.EventLogTarget.InitializeTarget() zh c:\NLogBuild\src\NLog\Targets\EventLogTarget.cs:línea 175 en NLog.Targets.Target.Initialize(LoggingConfiguration 配置) zh c:\NLogBuild\src\NLog\Targets\Target.cs:linea 288. 2013-06-10 12:21:05.0708 信息正在关闭日志记录... 2013-06-10 12:21:05.0708 信息记录器已关闭。
【问题讨论】:
-
您拼错了机器名称。