Hi, I'm playing around with the latest version of ...
# prefect-server
m
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
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
Hm, we have explicit coverage in our tests (and have done manual QA) for logging from tasks
m
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
Which task runner are you using?
Are you setting the logging level as an environment variable in your
FlowRunner
?
1
m
It was the env variable in the flow runner indeed. Thx for the help!
a