Skip to content

Instantly share code, notes, and snippets.

@duncansmart
Last active December 22, 2015 06:09
Show Gist options
  • Save duncansmart/6429028 to your computer and use it in GitHub Desktop.
Save duncansmart/6429028 to your computer and use it in GitHub Desktop.
Custom Audit Event

Custom Audit Class:

using System.Web.Management;
...
public class MyAuditEvent : WebAuditEvent
{
    public MyAuditEvent(string message, object eventSource, int eventCode)
        : base(message, eventSource,
               (eventCode < WebEventCodes.WebExtendedBase ? WebEventCodes.WebExtendedBase + eventCode : eventCode))
    {

    }
}

Web.config:

<healthMonitoring enabled="true">
  <eventMappings>
    <add name="MyAuditEvent" type="FooBar.MyAuditEvent, FooBar" />
  </eventMappings>
  <rules>
    <add name="MyAuditEvent to EventLog" eventName="MyAuditEvent" provider="EventLogProvider" profile="Default"  />
  </rules>
</healthMonitoring>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment