https://prefect.io logo
Title
m

Mathijs Carlu

02/21/2022, 3:04 PM
Hi, I'm playing around with the latest version of prefect orion (2.0a12), which atm runs on a local kubernetes cluster. I would like to log from inside a task, but currently don't manage to do so. Logging from a flow works however. How can I fix this? I'm using
get_run_logger().info('message')
, as the
print()
function also does not seem to produce any logs.
a

Anna Geller

02/21/2022, 3:25 PM
Can you try retrieving the logger first and then adding logs as here?
from prefect import task, get_run_logger

@task
def marvins_favorite_task():
    logger = get_run_logger()
    <http://logger.info|logger.info>("Hello from the Marvin's favorite task!")
z

Zanie

02/21/2022, 4:46 PM
Hm, we have explicit coverage in our tests (and have done manual QA) for logging from tasks
m

Mathijs Carlu

02/22/2022, 8:44 AM
It seems to be a problem with the logging level: I was actually logging on debug level (with env var PREFECT_LOGGING_LEVEL set to "DEBUG" as stated here: https://orion-docs.prefect.io/concepts/logs/), but these logs are not shown in the UI. I now tried to set the level of all loggers in the default .prefect/loggers.yml file to "DEBUG", but still don't see these logs. Is there some other log setting I might have forgotten?
z

Zanie

02/22/2022, 5:00 PM
Which task runner are you using?
Are you setting the logging level as an environment variable in your
FlowRunner
?
1
m

Mathijs Carlu

02/23/2022, 12:53 PM
It was the env variable in the flow runner indeed. Thx for the help!
a

Anna Geller

02/23/2022, 1:31 PM