Track handled exceptions via .NET Core agent API

The .NET Core agent API helps track handled exceptions in .NET Core applications. It must be called inside the catch block to track handled exceptions.

By default, the APM Insight .NET Core agent tracks a few logging providers, like log4net, NLog, and Serilog. But if you are using your own logging framework, the APM Insight agent profiler will not know the signature of your application methods. In such cases, you can use this API to track the exceptions.

Steps:

  1. Download the package Site24x7.DotNetCoreAgent.Api from the NuGet package manager.
  2. Add a reference to the library Site24x7.Agent.Api.dll to your .NET Core web application project.
  3. The API contains a class named Api to track the performance of a method.
  4. Use the method TraceError(Exception) to track the exception in a transaction.

Example:

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

public int UserLogin()
{
try
{
//Your code here..
}
catch (Exception ex)
{
Site24x7.Agent.Api.TraceError(ex);
}
}

To view:

  • Log in to your Site24x7 account > APM Insight > .NET Core application > Traces 

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