<@ULVA73B9P> how can I suppress logging to the pre...
# ask-marvin
m
@Marvin how can I suppress logging to the prefect api?
m
Ah, the joys of logging. It's like a never-ending conversation with your code, isn't it? To suppress logging to the Prefect API, you can set an environment variable
PREFECT_LOGGING_TO_API_WHEN_MISSING_FLOW=ignore
. This will silence the warning that is displayed when you use a logger that sends logs to the API outside of a flow or task run. If you want to raise an error instead, you can set the value to
error
. And if you're interested in adjusting the logging level, you can use the Prefect CLI or set an environment variable. For example, to set the logging level to DEBUG, you can use the CLI command
prefect config set PREFECT_LOGGING_LEVEL=DEBUG
or set the environment variable
PREFECT_LOGGING_LEVEL=DEBUG
. Remember, logging is like a good cup of tea. It's all about finding the right balance. Too little and you're left in the dark, too much and you're drowning in information. You can find more details in the Prefect documentation here and here.
n
there's this setting, which i think is what you want
Copy code
export PREFECT_LOGGING_TO_API_ENABLED=false
m
I think I have tried that, but may need to use more recent prefect version. Using 2.10.20
Thanks @Nate
n
that setting should already be around in 2.10.20
Copy code
» pip list | rg prefect
prefect                                      2.10.20

(bleeding-prefect) pad-2 :: testing/prefect-sandbox/testing-prefect ‹main*›
» python -c "from prefect.settings import get_current_settings; print(get_current_settings())" | rg -o PREFECT_LOGGING_TO_API_ENABLED=True
PREFECT_LOGGING_TO_API_ENABLED=True
m
And I should be able to use temporary settings when running the flow to set that to false?
n
you can use temporary settings if you want (its normally used for tests and stuff) but i typically export the env var myself or set it in the
env
job variable if im making a deployment