【问题标题】:Create folder structure in EventLog using NLog使用 NLog 在 EventLog 中创建文件夹结构
【发布时间】:2019-11-27 12:32:37
【问题描述】:

我正在尝试使用 NLog 在事件日志中创建文件夹结构。
我可以在“应用程序和服务日志”中创建日志,但我真正想要的是:

我在 nlog.config 文件中的目标:

<target name="eventLog" xsi:type="EventLog" source="EventLogSource" log="Foo/Bar" category="Test" eventId="TestID">
  <layout xsi:type="XmlLayout">
    <attribute name="logger" layout="${logger}" />
    <attribute name="level" layout="${level:upperCase=true}"/>
    <attribute name="message" layout="${message}" />
    <attribute name="exception" layout="${exception}" />
  </layout>
</target>

如果可以做到的话,有谁知道如何做到这一点?

【问题讨论】:

标签: .net nlog event-log


【解决方案1】:

试试这个

<target
      name="eventLog"
      xsi:type="EventLog"
      fileName="../../../Logs/${shortdate}/${shortdate}_Logs.txt"
      layout="${longdate} | ${level:uppercase=true} | ${stacktrace:format=Raw} | ${message} ${newline}">
    </target>

【讨论】:

  • EventLog 目标没有文件名属性?抱歉,这是错误的,令人困惑
猜你喜欢
  • 2021-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多