Sentry SDK带有ASP.NET 4.6.1不起作用
我有一个ASP.NET应用,使用.NET 4.6.1版本。当我安装了哨兵Nuget并使用Sentry SDK时,什么都没有工作,没有将事件发送给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>
谁能帮我吗?谢谢
I have an Asp.Net app, using .net 4.6.1 version. When I installed Sentry nuget and used Sentry SDK, nothing working, no events are being sent to Sentry. Below is global.asax configs where I tried this Sentry.
<%@ 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>
Can anyone help me? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅文档中的样本在这里。具体来说,您需要按以下方式更改代码:
o.addaspnet();
sentrysdk.init 呼叫server.capturelasterror()
在您的application_error
方法中,如果要启用Sentry的性能监视功能,您还需要:
在您的选项中设置tracessAmplerate
添加以下代码:
在
{
context.startsentrytransaction();
}
受保护的void application_endrequest()
{
context.finishsentrytransaction();
}
Refer to the sample in the documentation here. Specifically, you need to change your code as follows:
o.AddAspNet();
to the body of yourSentrySdk.Init
callServer.CaptureLastError()
in yourApplication_Error
methodIf you want to enable Sentry's performance monitoring features, you also need to:
Set a
TracesSampleRate
in your optionsAdd the following code: