答案 0 :(得分:5)
答案 1 :(得分:1)
为了在所有WebApi中执行此操作作为ExceptionLogger将错误记录到New Relic
将以下类添加到项目中
public class NewRelicExceptionLogger : ExceptionLogger
{
public override void Log(ExceptionLoggerContext context)
{
NewRelic.Api.Agent.NewRelic.NoticeError(context.ExceptionContext.Exception);
}
}
并在Global.asax.cs
下注明Application_Start()
:
protected void Application_Start()
{
//...
GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new NewRelicExceptionLogger());
}