Adding Windows Eventlogs as Destination for NLog Subsystem (and Job Servers)

Hi guys,
Maybe someone knows a bit more in configuring NLOG than I do.
I'm trying to send all logs generated by the JobServer-Component to a Windows Eventlog instead of to a file. Up until now I didn't succeed :-/
What I did so far is:
Downloaded the Windows Eventlog "sink" from nlog and copy the dlls to the OIM-Directory.
"Installed" the dlls with Nuget
Registered the dlls with .Net-Libraries in the OS

The error message I see in the nlog-verbose-log is:
2023-07-14 19:35:38.7420 Warn Error has been raised. Exception: NLog.NLogConfigurationException: Target 'One Identity' not found for logging rule: *.

The corresponding config in global.cfg is:
<extensions>
<add assembly="NLog.WindowsEventLog" />
</extensions>
<targets>
<default-wrapper xsi:type="AsyncWrapper" batchSize="1000" overflowAction="Block" timeToSleepBetweenBatches="0" />

<target xsi:type="EventLog"
name="One Identity"
source="One Identity Manager"
eventId="${event-properties:EventId:whenEmpty=0}"
layout="${message}${newline}${exception:format=ToString}" />
</targets>

Maybe anyone can help me in configuring Nlog correctly?

Cheers,
 Philipp

  • Hi Philipp, OneIM already writes fatal errors via NLog into the Windows Eventlog. When you look into the globallog.config, you will see the eventLog target defined, as well as a logger rule to write any fatal error into the eventLog target. To avoid getting you logging customization wiped out by Autoupdate, you can use the prepared includes of custom-log-variables.config and custom-log-targets.config. Best regards

  • Hi Andreas,
    Thx for pointing this out. That setting wasn't there in my globallog.config since it was obviously modified by somebody else in the past.
    If I modify the eventLogLevel OIM starts to write to the Application Log. For whatever reason it ignores a custom log specified as below:

    <target xsi:type="EventLog"
    name="One Identity"
    source="One Identity Manager"
    eventId="${event-properties:EventId:whenEmpty=0}"
    layout="${message}${newline}${exception:format=ToString}" />

    Cheers,
     Philipp

  • Hi Philipp,

    some thoughts:
     - Is there a logger entry matching your targets name?  ( writeTo="One Identity" )
     - Does this logger entry have a proper level or minlevel attribute?
     - Entries are case sensitive.
     - There might be a permission issue. Has the JobService the permission to write to the event log?
    Best regards,
    Andreas