This question covers how to manually notice errors in NewRelic in Ruby.
I need to do the same thing in C#.
How can I manually send errors to NewRelic in .NET?
This question covers how to manually notice errors in NewRelic in Ruby.
I need to do the same thing in C#.
How can I manually send errors to NewRelic in .NET?
According to NewRelic's .NET Api, you can do this with
NewRelic.Api.Agent.NewRelic.NoticeError(ex);
where ex
is an Exception
.
In order to do this across all WebApi as an ExceptionLogger to log errors into New Relic
Add the following class to your project
public class NewRelicExceptionLogger : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
NewRelic.Api.Agent.NewRelic.NoticeError(context.ExceptionContext.Exception);
}
}
and register it Global.asax.cs
under Application_Start()
:
protected void Application_Start()
{
//...
GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new NewRelicExceptionLogger());
}