azure-functions-python-worker icon indicating copy to clipboard operation
azure-functions-python-worker copied to clipboard

[FeatureRequest] support for filtering logs

Open bmc-msft opened this issue 4 years ago • 3 comments

User functions have a single global log level. It would beneficial to enable an consistent mechanism to add filter logging prior to the logs hitting app-insights.

bmc-msft avatar Sep 22 '20 15:09 bmc-msft

Our guidance is to configure filtering on the host, is able to filter logs from the app, the Python language worker, as well as the host itself.

It is a bit difficult to figure out the log categories without going to App Insights. I have some samples here: https://github.com/anthonychu/functions-log-suppression

anthonychu avatar Sep 22 '20 16:09 anthonychu

As Anthony already mentioned, you could use host.json config to specify your log level. For Python specifically, we have a change that is pending deployment to fix DEBUG log level bug: https://github.com/Azure/azure-functions-python-worker/issues/735

stefanushinardi avatar Sep 25 '20 23:09 stefanushinardi

Many python libraries set their level to 'info' and include debug information at that level, including Azure SDK libraries. I want to set the info level for my app's logs, but not all of the logging from all of the libraries that I use.

If this was a standard python app, I would setup a logging.basicConfig with the default level to warning, then set my app specific logger to INFO. However, I don't have a direct handle to the azure functions worker's logging handle.

I could update the context of the azure_functions_worker.logger.handler on every execution to add this filtering, that seems fragile.

Is there way to handle this use case?

bmc-msft avatar Oct 01 '20 13:10 bmc-msft