Loading...
Area: Episerver Search & Navigation
Applies to versions: 12 and higher
Other versions:

Tracing events

Recommendations [hide]

With Episerver Search & Navigation (formerly Episerver Find), you can listen to tracing events raised internally in Episerver.Find assemblies. The events are raised in exceptional situations.

How it works

To receive events raised from the tracing API, you are required to register a listener by implementing the ITraceListener interface. The initialization code in Episerver Search & Navigation searches assemblies located in the current app domain and registers the implementations, if any, that exist.

Examples

Below is an example of a trace events listener which sends an email in case of an error.

using System.Collections.Generic;
using EPiServer.Find.Tracing;
public class TestTraceListener : ITraceListener
{
    public TestTraceListener()
    {
    }
    public virtual void Add(ITraceEvent traceEvent)
    {
        if (traceEvent.IsError)
        {
            MailAdmin(traceEvent.Exception,traceEvent.Message)
        }
    }
}
The interface of ITraceEvent looks like this:
public interface ITraceEvent
  {
    DateTime Timestamp { get; }
    ITraceable Source { get; }
    string Message { get; }
    bool IsError { get; }
    Exception Exception { get; set; }
  }

Use cases

These are some examples of how to work with event tracing.

Network issues when connecting to the index

You can use tracing to generate notifications of service exceptions. To do so, handle the following exceptions like this:

public class TestTraceListener : ITraceListener
  {
    public virtual void Add(ITraceEvent traceEvent)
      {
        if (traceEvent.IsError && traceEvent.Exception is typeof(ServiceException))
          {
            // inspect Response code to determine course of action
            AlertOperations(traceEvent.Exception,traceEvent.Message,"Find Index potentially down.")
          }
      }
  }

Document storage limit reached

This example generates a notification when the number of indexed items is reaching the limit configured in your Search & Navigation service subscription.

public class TestTraceListener : ITraceListener
  {
    public virtual void Add(ITraceEvent traceEvent)
      {
        if (traceEvent.IsError && traceEvent.Exception is typeof(ServiceException))
          {
            // if response code is 403 and message contains "Your account is not authorized to index more than"
            AlertAccountMgr(traceEvent.Exception,traceEvent.Message,"limit reached for Find License")
          }
      }
  }
Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 31, 2016

Recommendations [hide]