简体   繁体   中英

Azure Functions v2: logging customization in host.json

I would like to adjust the logging behavior of an Azure Functions app (v2, .NET Core). Therefore I adjusted the host.json as follows:

"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. Why?

Furthermore what does fileLoggingMode and its possible values never, always and debugOnly stand for? I haven't found a good explanation for that.

Thanks

I see no new logs in Application Insights. Why?

Since your log level is set to Information, are you doing Log.LogInformation() from your code ? If you are using Log.LogDebug() try changing it. More information about Log Filtering -> Docs

what does fileLoggingMode and its possible values never, always and debugOnly stand for?

By default the fileLoggingMode is set to debugOnly . Which means its helpful only when the function is published in Azure. If you want to see diagnostic logs for your function when running locally, you need to set it to always

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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