Azure 日志流日志丢失 - Java
在我的 Azure 函数中,我使用 SLF4J 进行日志记录(由 logback 支持)。 Application Insights 支持自动检测日志记录。自动收集日志的地方。详细信息此处。
但我发现随机丢失了很多日志。它们在运行期间存在,但在 LogStream 中查看时在其他时候会丢失。可能出了什么问题?
In my Azure Function, I am using SLF4J for logging (backed by logback). Application Insights supports auto-instrumented logging. Where the logs are automatically collected. Details here.
But I find that randomly a lot of logs get missed. They are present during a run and missing some other times when viewed in LogStream. What could be going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案并没有完全回答问题。我仍然发现这个问题存在。并且并不真正知道 LogStream 中丢失日志的原因。这令人沮丧。
您可能需要进一步注意的一件事是: 采样。从文档粘贴:
为了避免由于采样而过滤,请添加功能配置:
这不会遗漏任何内容。
有关更多详细信息,请访问:https: //learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#sampling
就我而言,我想包含所有日志。但对其他指标执行采样(例如依赖关系,包括对 REST API、数据库或文件系统的调用)。
另一种方式也是如此。将
host.json
编辑为:日志语句本身位于
Trace
下。所以我们排除了它的采样。对其余部分进行采样(依赖项、事件、PageView、请求)要验证上述配置是否按预期工作,请运行以下 kusto 查询:对
函数进行负载测试。在输出中,您应该在
Exception;Trace;Request
上看到 100要查看全套配置:https://learn.microsoft。 com/en-us/azure/azure-functions/functions-host-json#sample-hostjson-file
有选择地覆盖(不同日志的不同行为):https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#sampling-overrides-preview" microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#sampling-overrides-preview
This answer does not fully answer the question. I still find the issue present. And don't really know the cause for missing logs in LogStream. And it is frustrating.
One thing that you may want to further take care is: Sampling. Pasting from the docs:
To avoid filtering due to sampling, add the function configuration:
This does not omit anything.
For more details, visit: https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#sampling
In my case, I wanted to include all the logs. But perform sampling for other metrics (like dependencies which includes calls to REST API, database or a file system).
An alternative way as well. Edit your
host.json
as:The log statements as such go under
Trace
. So we exclude sampling for it. The rest are sampled (Dependency, Event, PageView, Request)To validate if the above config is working as expected, run the below kusto query:
Load test the function. In the output, you should see 100 across the
Exception;Trace;Request
To view full set of config: https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#sample-hostjson-file
To selectively override (different behavior for different logs): https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#sampling-overrides-preview