【问题标题】:Azure Functions v2: logging customization in host.jsonAzure Functions v2:在 host.json 中记录自定义
【发布时间】:2019-12-30 01:36:04
【问题描述】:

我想调整 Azure Functions 应用(v2、.NET Core)的日志记录行为。因此我将host.json调整如下:

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

这方面的两个问题:

自从我这样做后,我在 Application Insights 中看不到新日志。为什么?

此外,fileLoggingMode 及其可能的值 never、always 和 debugOnly 代表什么?我还没有找到很好的解释。

谢谢

【问题讨论】:

    标签: logging .net-core azure-functions


    【解决方案1】:

    我在 Application Insights 中看不到新日志。为什么?

    由于您的日志级别设置为信息,您是否在代码中执行Log.LogInformation()?如果您使用的是Log.LogDebug(),请尝试更改它。更多关于日志过滤的信息 -> Docs

    fileLoggingMode 及其可能的值 never、always 和 debugOnly 代表什么?

    默认情况下,fileLoggingMode 设置为 debugOnly。这意味着它仅在函数在 Azure 中发布时才有用。如果要在本地运行时查看函数的诊断日志,则需要将其设置为always

    【讨论】:

    猜你喜欢
    • 2020-11-17
    • 1970-01-01
    • 2020-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多