views:

63

answers:

2

I can't write to the event log with NLog. I've been able to write to the console and to a file. I've turned on exceptions in NLog and am receiving no feedback from NLog. Here is my NLog.config:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      throwExceptions="true">
    <targets>
        <target name="console" xsi:type="Console" layout="${message}" />
        <target xsi:type="EventLog" name="eventlog" layout="${message}" log="Application" source="aaaTest"/>
        <target xsi:type="File" fileName="log.txt" name="file"/>
    </targets>

    <rules>
        <logger name="*" minlevel="Debug" writeTo="eventlog,console,file" />
    </rules>
</nlog>

In Event Viewer, I am looking at "Event Viewer (Local)" > "Windows Logs" > "Application". However, I see no instances of "aaaTest" (my defined source) in the log.

Thanks in advanced.

A: 

I've just started trying NLog myself and had a problem and got a quick answer on its forum. Have you tried: http://nlog-project.org/forum.html#nabble+

Also, I would try adding a machine name. Optional, but worth a try.

http://nlog-project.org/wiki/EventLog_target

Steve
Adding a machine name didn't help. I'll give the NLog forum a try. Thanks.
sparks
A: 

It looks like the only way to write to the event log in Windows 7 is to run the application as administrator.

sparks