https://prefect.io logo
Title
b

Bradley Hurley

11/07/2022, 4:23 PM
Hi Prefect Folks - Is it possible to adjust the log level of a running flow? 🧵
Normally
INFO
is fine for our use case, but we have seen on occasion something goes wrong and the job pod consumes all the free memory on the kubernetes node and we would like to capture additional logs when we’ve detected abnormal memory usage.
k

Khuyen Tran

11/07/2022, 4:25 PM
Yes, with
prefect config set PREFECT_LOGGING_LEVEL="DEBUG"
b

Bradley Hurley

11/07/2022, 4:25 PM
Sorry, I should have stated I am on prefect 1.0.
In my testing it seemed like once a flow was running changing the log level didn’t have any impact.
k

Khuyen Tran

11/07/2022, 4:27 PM
b

Bradley Hurley

11/07/2022, 4:28 PM
I attempted to set the environment variable as well as via python setting the global log level to debug.
>>> import prefect
>>> logger = prefect.context.get("logger")
>>> logger.getEffectiveLevel()
20
>>> logger.setLevel("DEBUG")
>>> logger.getEffectiveLevel()
10
I have this code in my flow:
@task()
def log_debug():
    for i in range(10):
        logger = prefect.context.get("logger")
        logger.debug("Test Debug Message")
        sleep(30)