<@ULVA73B9P> i'm having problems with logging. If ...
# ask-marvin
d
@Marvin i'm having problems with logging. If i do this to check the default logging level and the value of PREFECT_LOGGING_LEVEL, i get different answers:
Copy code
from prefect.settings import PREFECT_LOGGING_LEVEL
import logging

print(f"{PREFECT_LOGGING_LEVEL} {logging.getLogger().level}")
# prints "30 INFO"
(note 30 is WARNING in python). This didn't use to happen. what's up?
m
The discrepancy you're observing between
PREFECT_LOGGING_LEVEL
and the root Python logger's level is due to how Prefect and Python handle logging configurations. By default, the root Python logger is set to output logs at the
WARNING
level (which corresponds to 30), while Prefect's default logging level is often set to
INFO
. Here's how you can understand and possibly resolve this: 1. Root Logger Configuration: The root Python logger's default level is
WARNING
. This is independent of Prefect's logging level settings. You can override this using the
PREFECT_LOGGING_ROOT_LEVEL
environment variable if needed. 2. Prefect's Logging Level: The
PREFECT_LOGGING_LEVEL
setting controls logging specifically for Prefect's components. If you want to ensure consistency, you might need to explicitly set both the Prefect logging level and the Python root logger level. 3. Environment Variables: You can set the environment variable
PREFECT_LOGGING_ROOT_LEVEL
to match
PREFECT_LOGGING_LEVEL
if you want both to reflect the same logging level. For further details on configuring logging in Prefect, you can refer to the Prefect Logging Documentation. If this behavior is new, consider checking if there have been changes in your environment or Prefect version that might affect logging configurations.
d
ahh thanks marvin. that behavior seems to have changed since 3.1.13, but using the
PREFECT_LOGGING_ROOT_LEVEL
does do the trick