[英]Sentry SDK with Asp.Net 4.6.1 Not working
我有一个 Asp.Net 应用程序,使用 .net 4.6.1 版本。 当我安装 Sentry nuget 并使用 Sentry SDK 时,没有任何工作,没有事件被发送到 Sentry。 下面是我尝试这个 Sentry 的 global.asax 配置。
<%@ Application Language="C#" %>
<%@ Import Namespace="Sentry" %>
<%@ Import Namespace="Sentry.AspNet" %>
<%@ Import Namespace="Sentry.Extensibility" %>
<script runat="server">
private IDisposable _sentry;
protected void Application_Start()
{
_sentry = SentrySdk.Init(o =>
{
o.Dsn = "dsn url";
});
// Initialize Sentry to capture AppDomain unhandled exceptions and more.
}
// Global error catcher
protected void Application_Error()
{
var exception = Server.GetLastError();
SentrySdk.CaptureException(exception);
}
protected void Application_End()
{
if (_sentry != null)
_sentry.Dispose();
}
</script>
谁能帮我? 谢谢
请参阅此处文档中的示例。 具体来说,您需要按如下方式更改代码:
o.AddAspNet();
到SentrySdk.Init
调用的主体Application_Error
方法中使用Server.CaptureLastError()
如果要启用 Sentry 的性能监控功能,还需要:
在您的选项中设置TracesSampleRate
添加以下代码:
protected void Application_BeginRequest() { Context.StartSentryTransaction(); } protected void Application_EndRequest() { Context.FinishSentryTransaction(); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.