自定义错误记录| Azure Monitor日志与应用程序见解

发布于 2025-02-12 05:12:24 字数 194 浏览 1 评论 0 原文

我们计划使用Azure实现自定义错误记录。我遇到了一些文章,建议使用Azure Monitor Logs或Azure应用程序见解。我们的错误记录包括以JSON格式存储每个异常详细信息。我们将以JSON格式将这些详细信息传递给Azure Monitor Logs或Azure Application Insights。在这种情况下,比其他优势是什么,这是最适合此要求的。谢谢。

We are planning to implement custom error logging using Azure. I came across few articles which suggest using Azure monitor logs or Azure application insights. Our error logging includes storing each exception details in JSON format. We will pass these details in JSON format to either Azure monitor logs or Azure application insights. What are the advantages over other in this scenario and which is best suit for this requirement. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍风燃霜 2025-02-19 05:12:24

Azure Application Insights是Azure Monitor的一部分,因此您不能在它们之间进行比较。如果您已经开发了自己的应用程序洞察力,则非常适合,因为它可以开箱即用,并且有SKD 大多数语言

您可以通过使用a telmetry intemetry Initializer 您可以 =“ https://learn.microsoft.com/en-us/azure/azure-monitor/App/asp-net-exceptions#custom-tracing-and-log-data” rel =“ nofollow noreferrer”>创建自己的 exceptionTelemetry 并丰富该:

var telemetry = new TelemetryClient();

try
{
    // ...
}
catch (Exception ex)
{
    var properties = new Dictionary<string, string>
    {
        ["Game"] = currentGame.Name
    };

    var measurements = new Dictionary<string, double>
    {
        ["Users"] = currentGame.Users.Count
    };

    // Send the exception telemetry:
    telemetry.TrackException(ex, properties, measurements);
}

自定义详细信息作为键/值对存储,因此您可以在需要时添加自己的JSON文档作为值。

Azure Application Insights is part of Azure Monitor, so you cannot do a comparison between them. If you have developed your own application Application Insights is a good fit as it will have some logging out of the box and there are SKDs for most languages

You can add additional details to telemetry logged by application insights by using a Telemetry Initializer or you can create your own ExceptionTelemetry and enrich that:

var telemetry = new TelemetryClient();

try
{
    // ...
}
catch (Exception ex)
{
    var properties = new Dictionary<string, string>
    {
        ["Game"] = currentGame.Name
    };

    var measurements = new Dictionary<string, double>
    {
        ["Users"] = currentGame.Users.Count
    };

    // Send the exception telemetry:
    telemetry.TrackException(ex, properties, measurements);
}

Custom details are stored as a key/value pair, so you can add your own json document as a value if needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文