0

I'm trying to create a folder structure in the eventlog using NLog.
I'm able to create logs in the 'Applications & Services logs' but what I really want is something like:
Folders in EventLog

My target in the nlog.config file:

<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>

Does anyone know how this can be done, if it can be done?

Hypenate
  • 1,907
  • 3
  • 22
  • 38
  • 1
    NLog can write to an EventLog-Source. But to register an EventLog-Source to be in a sub-folder, then you have to perform dark magic. See also: https://stackoverflow.com/questions/10428158/how-do-i-create-a-hierarchy-of-lognames-in-the-windows-event-system/10528920#10528920 – Rolf Kristensen Nov 27 '19 at 19:32

1 Answers1

-2

Try this

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