gpt4 book ai didi

java - 如何使用 Log4j 将自定义属性记录到 AppInsight?

转载 作者:行者123 更新时间:2023-12-02 23:00:17 24 4
gpt4 key购买 nike

我在网上和SO上查找了这个问题的答案。我没有看到任何答案,所以想知道这是否可能。我想使用 log4j 并将 JSON 格式的日志数据发送到 azure 的服务 AppInsight。我可以在那里获取 json 数据,但它以原始文本形式出现。我已经看到可以在这个用例中使用遥测,但我不想搞乱它。我只想要 log4j 来处理我的日志记录。是否可以将 JSON 记录到 azure 的 AppInsight 并让它将其识别为 json,然后使其数据可查询?如果是这样,怎么办?

最佳答案

请原谅,这将是一个有点链接繁重,但你有不同的选择,具体取决于你想要做什么,所以我试图在此处包含尽可能多的信息。

最近对 Application Insights 功能及其与 Azure Monitor 的关系进行了一些相对较新的更改,以巩固和澄清服务的角色。大多数涵盖数据收集器 API 和跨资源日志查询等内容的 Application Insights 文档现在都会将您发送到 Azure Monitor。因此,一些 Application Insights 功能已停用:

https://azure.microsoft.com/en-us/blog/analyze-your-data-with-application-insights-analytics/

"The functionality described in this blog was retired and no longerexist in Application Insights. Alternatively, you can send yourcustom log to the Azure Monitor log store, which is LogAnalytics. You can query this data from Log Analytics or yourApplication Insights resource using cross-resource queries."

因此,对于您描述的场景,您需要使用 Azure Monitor。您仍然可以在 Application Insights 中导入 log4j 文件,并且如果您愿意,可以利用 Application Insights API 来获取自定义事件和指标:

如果您想了解更多信息,这里有一些有用的链接:

关于java - 如何使用 Log4j 将自定义属性记录到 AppInsight?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63421001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com