Help APM APM Insight using .NET Agent Track exceptions via .NET agent API

Track exceptions via .NET agent API

The .NET agent API helps in keeping track of exceptions handled in .NET and .NET Core applications. To track handled exceptions, it must be called inside the catch block.

The APM Insight .NET agent tracks a few logging providers by default, including log4net, NLog, and Serilog. On the other hand, the APM Insight agent profiler will not know the signature of your application methods if you use your own logging framework. In such cases, you can use .NET agent API to track the exceptions.

Steps:

  1. Install APM Insight .NET agent or APM Insight .NET Core agent based on your application environment.
  2. Download or reference the package Site24x7.Agent.Api from the NuGet package manager to your application project.
    Note: The API has a class named Site24x7.Agent.Api  to track the performance of application code.
  3. Use the method TraceError(Exception exceptionObject)  to track any exception in a transaction.

Parameter Name

Description

 exceptionObject

The exception object  that you want to track.

Example:

The following method illustrates how to track an exception via API.

public int UserLogin()
{
          try
          {
                    MyClass myClass = ;
                    int b = 0;
                    int invalidResult = a / b;
          }
          catch (Exception ex)
         {
                       Site24x7.Agent.Api.TraceError(ex);
         }
}

To View:

Track exceptions via .NET agent API

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help APM APM Insight using .NET Agent Track exceptions via .NET agent API