Hide menu Last updated: Oct 31 2016
Area: Episerver Find Applies to versions: 12 and higher
Other versions:

Tracing events

With 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 interfaceThe initialization code in Episerver Find searches assemblies located in the current app domain and registers the implementations, if any, that exist.

Examples

Trace event listener

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

using System.Collections.Generic;
using EPiServer.Find.Tracing;

public class TestTraceListener : ITraceListener
{
    public static List traceEvents;

    public TestTraceListener()
    {
        traceEvents = new List();
    }

     public virtual void Add(ITraceEvent traceEvent)
    {
        traceEvents.Add(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

Network issues with connecting to Episerver Find Index

You can use tracing to generate notifications of service exceptions when working with Find. 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

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") }
} }

Comments