简体   繁体   English

Azure Functions v2:在host.json中记录自定义

[英]Azure Functions v2: logging customization in host.json

I would like to adjust the logging behavior of an Azure Functions app (v2, .NET Core). 我想调整Azure Functions应用(v2,.NET Core)的日志记录行为。 Therefore I adjusted the host.json as follows: 因此,我对host.json进行了如下调整:

"logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
        "default": "None",
        "Host.Results": "Information",
        "Function": "Information",
        "Host.Aggregator": "Information"
    },
    "applicationInsights": {
        "samplingSettings": {
            "isEnabled": false,
            "maxTelemetryItemsPerSecond": 5
        }
    }
}

Two questions in that context: 在这方面有两个问题:

Since I did that I see no new logs in Application Insights. 自从这样做以来,我在Application Insights中看不到任何新日志。 Why? 为什么?

Furthermore what does fileLoggingMode and its possible values never, always and debugOnly stand for? 此外,fileLoggingMode及其可能的值从不,总是和debugOnly代表什么? I haven't found a good explanation for that. 我还没有找到很好的解释。

Thanks 谢谢

I see no new logs in Application Insights. 我在Application Insights中看不到新日志。 Why? 为什么?

Since your log level is set to Information, are you doing Log.LogInformation() from your code ? 由于您的日志级别设置为“信息”,因此您正在从代码中执行Log.LogInformation()吗? If you are using Log.LogDebug() try changing it. 如果您使用Log.LogDebug()尝试对其进行更改。 More information about Log Filtering -> Docs 有关日志过滤-> 文档的更多信息

what does fileLoggingMode and its possible values never, always and debugOnly stand for? 从不,始终和debugOnly代表fileLoggingMode及其可能的值是什么?

By default the fileLoggingMode is set to debugOnly . 默认情况下, fileLoggingMode设置为debugOnly Which means its helpful only when the function is published in Azure. 这意味着仅当该功能在Azure中发布时它才有用。 If you want to see diagnostic logs for your function when running locally, you need to set it to always 如果要在本地运行时查看功能的诊断日志,则需要将其设置为always

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM