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.
Note: The API has a class named Site24x7.Agent.Api to track the performance of application code.
| Parameter Name | Description |
|---|---|
| exceptionObject | The exception object that you want to track. |
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

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