1

I have a C# console application trying to log events to my custom event log using NLog.

However, the log events are always written to the Application log and not to the one I have already configured. I am using NLog version 4.4.0. What am I missing here?

Here is the configuration in my App.config:

<code>

<configuration>
      <configSections>
        <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />

      </configSections>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        </startup>
      <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" internalLogToConsole="true" internalLogLevel="Trace">
        <targets>
          <target xsi:type="EventLog" name="eventLog" layout="${longdate}|${message}" source="MyCustomLogSource" log="MyCustomLog" machineName="." />
          <!-- note: source is a string in NLog before 4.0 -->

        </targets>
        <rules>
          <logger name="*" minlevel="Info" writeTo="eventLog" />
        </rules>
      </nlog>
    </configuration>

</code>
Julian
  • 33,915
  • 22
  • 119
  • 174
  • Why did you put the asp.net tag? It is a console application. – Bigeyes Dec 22 '16 at 16:47
  • 2
    isn't this is the problem also in your case? [NLog: can't write to event log](http://stackoverflow.com/questions/3161617/nlog-cant-write-to-event-log#4679613) – Paweł Łukasik Dec 22 '16 at 19:03
  • Possible duplicate of [NLog: can't write to event log](http://stackoverflow.com/questions/3161617/nlog-cant-write-to-event-log) – Julian Jan 11 '17 at 23:44

0 Answers0