在 Azure Functions 中,您使用 host.json 来配置日志记录。但是,我不清楚日志记录选项/部分。有人可以帮忙吗?
对此:https : //docs.microsoft.com/en-us/azure/azure-functions/functions-host-json
"logging": {
// FILE CONFIG?
"fileLoggingMode": "debugOnly"
"logLevel": {
"Function.MyFunction": "Information", // where is this log?
"default": "None"
},
// INSIGHTS CONFIG
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes" : "Dependency;Event",
"includedTypes" : "PageView;Trace"
},
我假设文件系统日志是通过 FILE CONFIG 部分控制的,对吗?
FileLoggingMode
用于在azure 门户或本地环境中生成日志。中的不同模式是“fileLoggingMode”
“debugOnly”:当函数应用在Azure 门户上运行时,此级别将生成日志。这是默认模式。
“always”:此模式用于在本地环境以及在Azure Portal上运行时生成日志。此代码参考有助于更好地理解它。
“从来没有”:这种模式也不会产生任何日志。
当“fileLoggingMode”
设置为“always”时,本地环境运行时生成的日志文件存放在“C:\Users{user}\AppData\Local\Temp\LogFiles\Application\Functions\Function{Function_Name}”,
路径中,可以在Host Settings代码中引用这里。如果您在本地将函数应用作为 docker/container 运行,则可以通过更新主机配置代码来更改路径。
在fileLoggingMode
仍处于问题看这里
在日志日志级别中,我们有参数default/function/…
,其中提到了我们需要获取哪种类型的日志(错误、信息、跟踪……)
{
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Function": "Error"
}
}
}
请参阅:为 Azure Functions 配置监控 | 微软文档
(host.json).
如果您正在使用,"default": "Error"
您将默认获取错误日志。如果您使用以下配置的默认它将得到Information Log
和Funcition获得Error log
。
"default": "Information",
"Function": "Error"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句