-
Notifications
You must be signed in to change notification settings - Fork 1
Logging: Eventlog
Usually NLog creates the necessary permissions to write inside the Application Log of Eventlog. If it is not working you need to create the permission yourself:
New-EventLog -LogName WebJEA-Source "WebJEA"
Info: The new Log doesnt show directly, I had to restart Windows to make it appear (or a full restart of the Eventlog Service)
In the file "NLog.config" inside the WebJEA Folder (C:\inetpub\wwwroot\webjea) is the Targets-Block where NLog writes its logfiles. There you can edit what Log you want to write to the Windows Eventlog.
Contents of webjea.log
<target name="eventlog" xsi:type="EventLog" source="WebJEA" log="WebJEA" layout="${longdate}|${level}|${counter}|${aspnet-TraceIdentifier}|${aspnet-user-identity}|${message}"/>
Contents of webjea-usage.log
<target name="eventlog" xsi:type="EventLog" source="WebJEA" log="WebJEA" layout="${longdate}|${aspnet-request-host}|${aspnet-user-identity}|${message}"/>
The last thing we need to edit is the Rule (what needs to be logged)
<logger name="*" minlevel="Trace" writeTo="eventlog" />
The default -> Trace