Nlog类型EventLog未在事件查看器中显示条目

时间:2016-04-07 06:57:34

标签: c# nlog eventlog-source

我在我的MVC Web Api应用程序中使用NLog。我使用NuGet包管理器安装了NLog,并在创建的Nlog.conf文件中配置了我的日志目标。

 <targets>
   <target xsi:type="EventLog"
           name="eventlog"
           source="ImageService"
           machineName="."
           log="Application"
           layout="${longdate}|${level}|${message}"/>
 </targets>
<rules>
   <logger name="*" minlevel="Debug" writeTo="eventlog" />
 </rules>

然后使用powershell注册了一个新事件。

New-EventLog -Logname Application -Source ImageService

现在在C#代码中我正在关注

Logger _log = LogManager.GetCurrentClassLogger();
_log.Info("Demo message);

但是当我去事件查看器 - &gt; Windows日志 - &gt;应用程序并根据源名称ImageService对其进行过滤,它不会在那里显示任何条目。

如果它有任何意义。上面的记录器代码写在单独的类库中,然后在Web应用程序中引用它并调用日志函数。

我的目标和规则配置有什么问题吗?

0 个答案:

没有答案
相关问题