https://prefect.io logo
Title
b

Bryan Whiting

01/24/2023, 10:50 PM
I have
export PREFECT__LOGGING__LEVEL=DEBUG

def main(): 
    logger = get_run_logger()
    logger.warning("warning")
    logger.debug("debug")
    <http://logger.info|logger.info>("info")
    logger.critical("critical")
yet the debug isn’t printing:
14:49:20.921 | WARNING | Flow run 'wonderful-hamster' - warning
14:49:20.921 | INFO    | Flow run 'wonderful-hamster' - info
14:49:20.922 | CRITICAL | Flow run 'wonderful-hamster' - critical
1
n

Nate

01/24/2023, 11:12 PM
Hi @Bryan Whiting - are you using two underscores when trying to set
PREFECT_LOGGING_LEVEL
? the setting name has single underscores
❯ prefect config set PREFECT__LOGGING__LEVEL="DEBUG"
Unknown setting name 'PREFECT__LOGGING__LEVEL'.

❯ prefect config set PREFECT_LOGGING_LEVEL="DEBUG"
Set 'PREFECT_LOGGING_LEVEL' to 'DEBUG'.
🙌 1
t

Timo Vink

01/24/2023, 11:18 PM
Not Bryan but was following along with a similar issue. For me even setting the correct env variable in code before running my flow I still wasn't getting DEBUG logs. Figured it out, sharing in case it helps anyone else: The env var must be set before
prefect
is imported. Setting it after prefect is imported but before
get_run_logger
is called isn't early enough.
👍 1
b

Bryan Whiting

01/24/2023, 11:19 PM
PREFECT__LOGGING__LEVEL=DEBUG
thanks for the help!
n

Nate

01/24/2023, 11:20 PM
sure thing! are you using prefect 2 or prefect 1? i assumed you meant prefect 2 but the docs you linked are prefect 1
b

Bryan Whiting

01/24/2023, 11:20 PM
dang, i’m using 2. i’ll be more careful about lookig for that. thank you!
yes, and now it’s working! thank you!
n

Nate

01/24/2023, 11:21 PM
no problem - lots of things are changing quickly as we shift into the world of prefect 2! happy to help
also @Timo Vink, in case its helpful you should be able to adjust
PREFECT_LOGGING_LEVEL
at the profile level whenever you like (relative to package import) using the
prefect config set KEY=VAL
not sure off the top about the timing when using a standard shell env var
t

Timo Vink

01/24/2023, 11:25 PM
Thanks. They "look like env vars" so I was just using
os.environ
. Profile indeed seems like the better way to set this!
:party-parrot: 1