Azure功能详细的跟踪日志记录到Application Insights [英] Azure function verbose trace logging to Application Insights
问题描述
我有一个连接到App Insights实例的Azure功能.该功能应用程序会发出日志消息,这些消息可以在Azure门户的日志流中以及App Insights跟踪中看到.
I have an Azure function that's connected to an App Insights instance. The function app emits log messages which I can see in the log stream in the Azure portal, and as App Insights traces.
I've increased the console log level to Verbose by adding a "tracing"
element to host.json
(https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json), so Verbose level messages show up in the log stream (in both the function page in the Azure portal, and in Kudu), but I can't get Verbose level traces to appear in App Insights.
有人知道如何获取App Insights以显示Azure函数的详细级别跟踪吗?可能吗?(信息痕迹及以上信息在App Insights中显示得很好)
Does anyone know how to get App Insights to show Verbose level traces from an Azure Function? Is it even possible? (Info traces and above are showing up just fine in App Insights)
推荐答案
对于函数"中的应用洞察",您对日志级别有很多控制权,但是您没有将 tracing
元素用于这些.我们正在努力将文档集中在一起,但是下面的一些链接可以提供帮助:
You have a lot of control over your log levels for App Insights in Functions, but you don't use the tracing
element for these. We're working on pulling the docs together in one cohesive location, but here's some links that can help:
- 新的
logger.categoryLevel
host.json设置: https://github.com/Azure/azure-webjobs-sdk/wiki/Application-Insights-Integration#filtering
- The new
logger.categoryLevel
host.json settings: https://github.com/Azure/Azure-Functions/wiki/App-Insights-(Preview)#hostjson-settings - The WebJobs documentation, which gives a bit more detail on how the category filter works (behind the scenes, the host.json settings are serialized into this): https://github.com/Azure/azure-webjobs-sdk/wiki/Application-Insights-Integration#filtering
对于您的特定示例,您可以在主机中打开所有 Debug
日志(与 TraceWriter
中的 Verbose
匹配).json:
For your specific example, you can open up all the Debug
logs (which matches Verbose
in TraceWriter
) with this in your host.json:
{
"logger": {
"categoryFilter": {
"defaultLevel": "Debug"
}
}
}
如果您只想查看来自功能本身的详细日志(即,您不希望出现主机的详细日志),则可以对此进行限制-对于功能"类别的日志来说,这表示"(这是功能日志使用的类别),向我展示Debug或更高级别的日志的所有内容':
If you just want to see the verbose logs coming from your Function itself (i.e. you don't want the host's verbose logs appearing), you can restrict that with this -- which says 'for logs with the "Function" category (which is the category that function logs use), show me everything with Debug or higher log level':
{
"logger": {
"categoryFilter": {
"categoryLevels": {
"Function": "Debug"
}
}
}
}
这篇关于Azure功能详细的跟踪日志记录到Application Insights的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!