2 people following this project (follow)

Once you download the binaries it's quite simple and straight forward to configure your web applications to use it.

You just need to append or configure the system.web/healthMonitoring section within your web.config file with the following configuration snippet:

  <healthMonitoring enabled="true">
   <providers>
    <add name="trace" type="System.Web.Management.TraceWebEventProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add source="EventLogSourceName" name="eventlog" type="NG.Web.Management.EventLogWebEventProvider, NG.Web.Management" />
   </providers>
   <rules>
    <clear />
    <add name="Application Lifetime Events Default" eventName="Application Lifetime Events"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
    <add name="Request Processing Events Default" eventName="Request Processing Events"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
    <add name="All Errors Trace" eventName="All Errors" provider="eventlog"
     profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
    <add name="Infrastructure Errors Default" eventName="Infrastructure Errors"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
    <add name="Request Processing Errors Default" eventName="Request Processing Errors"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
    <add name="Failure Audits Default" eventName="Failure Audits"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
    <add name="Failure Viewstate Events Default" eventName="Failure Viewstate Events"
     provider="eventlog" profile="Default" minInstances="1" maxLimit="Infinite"
     minInterval="00:00:00" />
   </rules>
   <eventMappings>
    <add name="Failure Viewstate Events" type="System.Web.Management.WebViewStateFailureAuditEvent, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     startEventCode="0" endEventCode="2147483647" />
    <add name="All Management Events" type="System.Web.Management.WebManagementEvent, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     startEventCode="0" endEventCode="2147483647" />
   </eventMappings>
  </healthMonitoring>

Before start using your application you must ensure the EventLog SourceName you intend to use exists. If not, you can easily create it using this simple PowerShell script:

$creationData = new-object System.Diagnostics.EventSourceCreationData("EventLogSourceName", "Application")  
$creationData.CategoryCount = 5
$creationData.CategoryResourceFile = "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_rc.dll"
$creationData.MessageResourceFile = "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_rc.dll"

if (![System.Diagnostics.EventLog]::SourceExists($creationData.Source))
{      
	[System.Diagnostics.EventLog]::CreateEventSource($creationData)  
} 

if ([System.Diagnostics.EventLog]::Exists($creationData.LogName))
{
	$eventlogs = [System.Diagnostics.EventLog]::GetEventLogs()
	foreach ($evtlog in $eventlogs)
	{
		if ($evtlog.Log -eq $creationData.LogName)
		{
			$evtlog.ModifyOverflowPolicy([System.Diagnostics.OverflowAction]::OverwriteAsNeeded, $evtlog.MinimumRetentionDays);
			$evtlog.MaximumKilobytes = 20096;
		}
	}
}

and change it accordingly.

Last edited Apr 30 2011 at 12:24 AM by nmgomes, version 6

Comments

No comments yet.