WCF.Instrumentation 1.0.0

dotnet add package WCF.Instrumentation --version 1.0.0
NuGet\Install-Package WCF.Instrumentation -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WCF.Instrumentation" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WCF.Instrumentation --version 1.0.0
#r "nuget: WCF.Instrumentation, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WCF.Instrumentation as a Cake Addin
#addin nuget:?package=WCF.Instrumentation&version=1.0.0

// Install WCF.Instrumentation as a Cake Tool
#tool nuget:?package=WCF.Instrumentation&version=1.0.0

Instrumentation is provided using the event provider model. Events are notifications which you receive from the WCF application which can be a security event like password change, UI click events, or exception events like application level errors. These events are captured by the provider and routed to some source like event viewer, SQL Server, etc.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 2,037 3/23/2015

How to implement:

In your service contract implement the health audit functionality

 [ServiceContract]
   public interface IService
   {
       [OperationContract]
       string Audit();
   }

In the Service.svc.cs class, implement the Audit function by creating the CustomAudit object and calling the Raise function

public class Service : IService
{
   public string Audit()
   {
       Healthmonitering.CustomAudit webevent =
                               new Healthmonitering.CustomAudit("Some on called",
                   this, WebEventCodes.WebExtendedBase + 1);
       webevent.Raise();
       return "Event Audited";
   }
}

In the web.config and under system.web element, add a healthmonitoring tag.
Specify CustomAudit class in the eventMappings element and mapping of the class with event viewer in the rules element tag

<healthMonitoring>
<eventMappings>
<add name="healthmonitering" type="Healthmonitering.CustomAudit "/>
</eventMappings>
<rules>
<add name="healthmonitering" eventName="healthmonitering"
               provider="EventLogProvider" minInterval="00:00:01"/>
</rules>
</healthMonitoring>


Finally, consume the client service and call the Audit function in the button click event

protected void Button_Click(object sender, EventArgs e)
{
   ServiceReference1.Service1Client proxy =
                               new WebApplication1.ServiceReference1.Service1Client();
   string result = proxy.Audit();
   Response.Write(result);
}

End result will be captured in the event logs like:

***************start health monitoring event*******************
message created at:Event Created at :3/23/2015 11:32:37 AM
message raised at:Event Created at :3/23/2015 11:32:37 AM
Heap size 2584335
Number of threads 14
Number of Working sets 32165888
Number of domains 1
Request rejected 0
******************End Health Monitoring event*********************