WCF Web Services and ASP.NET Native Health Monitoring

I need a definitive answer to the next question! :-)

I was wondering if health monitoring can be enabled for WCF web services. I host several services on IIS and have configured it to send a command email notification when any exceptions are thrown. I believe that health monitoring does not work with WCF services and that I need to configure WCF trace http://msdn.microsoft.com/en-us/library/ms733025.aspx

thank

+3
source share
1 answer

I tried it too, but all the solutions looked too complicated.

.

WebEvent. :

public class SyncError : WebBaseErrorEvent
{
  public SyncError(string message, Exception e)
    : base(message, "Sync", WebEventCodes.WebExtendedBase + 1, 0, e)
  {    
  }

  public override void FormatCustomEventDetails(WebEventFormatter formatter)
  {
    base.FormatCustomEventDetails(formatter);
    formatter.AppendLine(ErrorException.ToString());
  }
}

:

// WCF method
public int Sync()
{
  try
  {
    // do normal stuff
  }
  catch (Exception ex)
  {
    var e = new SyncError("Error in Sync", ex);
    e.Raise();
    throw;
  }
}

, web.config:

<eventMappings>
  <add name="Sync Errors" type="SyncLibrary.SyncError, SyncLibrary"/>
</eventMappings>

<rules>
  <add name="Sync Errors SQL" eventName="Sync Errors" 
       provider="SqlWebEventProvider"
       profile="Default" 
       minInstances="1" 
       maxLimit="Infinite" 
       minInterval="00:00:00" />
</rules>

. , .

+2

Source: https://habr.com/ru/post/1747488/


All Articles