0

I'm running pytest.main(["some", "args"]) inside my Azure function (I understand pytest could be run as part of a devops pipeline and not inside my function but bear with me). When deployed to the portal, clicking on Test/Run, I cannot see any of the pytest output neither in the logs nor in Monitor > Invocation Traces. I have Application Insights activated and can see all the logging statements except for the pytest output.

This works fine locally when running on VSCode and the Azure Functions Core Tools. For example: enter image description here

Whereas online I only see the green, and would need to see the blue as well: enter image description here

My host.json contains:

  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false
      }
    },
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Trace",
      "Host.Results": "Trace",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }

I'm trying with pytest's command line options, eg. --log-level=DEBUG -o log_cli=true -o log_cli_level=DEBUG, as well as the --capture flags, but no luck.

Am I not giving pytest.main() the right args? Or does it have to do with how the Azure portal runs my function, perhaps it takes over the logging and messes with pytest? I've tried printing out the loggers but I'm not seeing much.

EDIT: I am actually seeing more detailed logs when I query the logs, in the traces table. How come they are not getting printed in the logs under Test/Run or Invocation Traces?

enter image description here

3
  • Can you provide the sample code snippet so that we can look further ? Oct 7, 2022 at 12:09
  • It's fine, if I can see the logs by querying the traces table, I'm content. Most of my executions happen at a distance and not through the Test/Run panel anyway.
    – Salazaja
    Oct 7, 2022 at 12:15
  • Your host.json configuration looks good. You are keeping lower-level severity of logs so it will keep all the metrics lower and higher-level logs. To check further you can share sample code Oct 10, 2022 at 2:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.