Search code examples
asp.net.net-3.5iis-7permissionsevent-log

What do I need to change to allow my IIS7 ASP.Net 3.5 application to create an event source and log events to Windows EventLog?


ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.

        if (!EventLog.SourceExists("MyAppLog"))
            EventLog.CreateEventSource("MyAppLog", "Application");

        EventLog myLog = new EventLog();
        myLog.Source = "MyAppLog";
        myLog.WriteEntry("Message");

Solution

  • This is part of windows security since windows 2003.

    You need to create an entry in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application Make sure that network service or the account you impersonate has permission to this registry key.

    @CheGueVerra's link: Requested Registry Access Is Not Allowed