Schedule demo

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 catchblock.

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 NuGet package 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 NameDescription
    exceptionObjectThe 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

APM Insight .NET agent Track exceptions via .NET agent API: Traces summary tab

Loved by customers all over the world

"Standout Tool With Extensive Monitoring Capabilities"

It allows us to track crucial metrics such as response times, resource utilization, error rates, and transaction performance. The real-time monitoring alerts promptly notify us of any issues or anomalies, enabling us to take immediate action.

Reviewer Role: Research and Development

carlos-rivero
"I like Applications Manager because it helps us to detect issues present in our servers and SQL databases."
Carlos Rivero

Tech Support Manager, Lexmark

Trusted by thousands of leading businesses globally