I have a .NET Core Console app where I use NLog. When I try to add EventLog as target in the nlog.config the load of the configuration failes with the following:
System.ArgumentException: Target cannot be found: 'EventLog'.
I have found a similar question in stackoverflow: NLog not writing to eventlog .NET Core 2.1. And the suggested solution is to add the Nuget-package NLog.WindowsEventLog which I have. And the version I have downloaded is 4.5.10 so it should not have the bug in v. 4.5.7 mentioned in the other stackoverflow post. And it still does not work.
Here is some information:
And here is the nlog.config:
<?xml version="1.0" encoding="utf-8" ?>
<!-- XSD manual extracted from package NLog.Schema:
https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="logs\internal-log.log"
internalLogLevel="Trace" >
<!-- the targets to write to -->
<targets>
<target xsi:type="EventLog" name="eventlog" source="testlogging"
log="Application" layout="${message}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<logger name="*" minlevel="Trace" writeTo="eventlog" />
</rules>
</nlog>
Have I missed something?
add to your config, after the <nlog ...>
<extensions>
<add assembly="NLog.WindowsEventLog"/>
</extensions>
if that won't work, check the internal log: https://github.com/NLog/NLog/wiki/Internal-logging