Search code examples
iisevent-log

eventloglistener wont write to eventlog on server


I have a eventloglistener setup like this:

<trace autoflush="true" indentsize="2">
<listeners>
<!--<remove name="Default" />-->
<add name="EventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="myproj" />
</listeners>
</trace>
<switches>
<!--
    "0" Off            
    "1" Error messages            
    "2" Warning, gives Error and Warning messages            
    "3" Information, gives Error, Warning and Information messages            
    "4" Verbose, gives Error, Warning, Information and Verbose messages
    -->
<add name="myproj" value="4" />
</switches>

It works fine when running local, but when releaseing to my server nothing is written. Why is that? Do I need to grant some permissions?


Solution

  • This had to do with some permissions.

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog\Application

    Create CustomSD (if not exists) and set the value: https://support.microsoft.com/en-us/kb/2028427