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?
Copy code
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
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?
Zanie
02/22/2022, 5:00 PM
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!
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.