question

UngTsuHan-8105 avatar image
0 Votes"
UngTsuHan-8105 asked MughundhanRaveendran-MSFT commented

Azure Function 1.x Override Log Level via Application Setting In Portal

Currently, I still have some existing Azure Function in 1.x version.

I plan to implement CICD to apply different log level for different environment
- dev, stage: Information
- prod: Error

For Function App 2.x, I am able to configure app setting in release during devops
- example: AzureFunctionsJobHost_logginglogLevel_Default: Error

For Function App 1.x, I am not able to find any example resource to achieve similar result.

By referring to structure of host.json in 1.x https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json-v1?tabs=2x-durable-functions#sample-hostjson-file
I follow the structure of key value pair. AzureFunctionsJobHost_loggercategoryFilter_defaultLevel
But that is not working.



azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MughundhanRaveendran-MSFT avatar image
0 Votes"
MughundhanRaveendran-MSFT answered MughundhanRaveendran-MSFT commented

@UngTsuHan-8105 ,

Thanks for reaching out to Q&A.

There are lots of changes between V2+ and V1 of function app. I would suggest you to make changes to the host.json rather than changing the app settings. You can change the values (as per your requirement) of the logger in the host.json as specified below.

"logger": {
"categoryFilter": {
"defaultLevel": "Information",
"categoryLevels": {
"Host": "Error",
"Function": "Error",
"Host.Aggregator": "Information"
}
}
},

Please look at this article for supported values : https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json-v1?tabs=2x-durable-functions#logger

Feel free to reach out to me if you have any queries or concerns.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MughundhanRaveendran-MSFT

Thanks. I have tried this method by specifying in host.json.

However, I plan to create a pipeline for staging and production, where by my staging want have information loglevel while prod want to have error loglevel.

Is there any workaround to achieve that?

Thanks.


0 Votes 0 ·

@UngTsuHan-8105 , In that case, you can have 2 different host.json files in the artifacts. One for staging and one for production. Please let me know if this approach doesnt work for you

0 Votes 0 ·