Syméon del Marmol
08/29/2025, 5:00 PMMarvin
08/29/2025, 5:00 PMMarvin
08/29/2025, 5:05 PMPREFECT_LOGGING_SETTINGS_PATH
to that file. Also disable API logging.
- Example YAML that leaves Prefect with no handlers so your own loggers/handlers are in charge:
version: 1
disable_existing_loggers: False
handlers: {}
loggers:
prefect:
level: NOTSET
handlers: []
propagate: True
prefect.flow_runs:
level: NOTSET
handlers: []
propagate: True
prefect.task_runs:
level: NOTSET
handlers: []
propagate: True
root:
level: NOTSET
handlers: []
- Environment:
PREFECT_LOGGING_SETTINGS_PATH=/path/to/logging.yaml
PREFECT_LOGGING_TO_API_ENABLED=false
PREFECT_LOGGING_LOG_PRINTS=false
This ensures Prefect does not attach console/API handlers and does not redirect prints; logs from Prefect (if any) will propagate into whatever handlers you configure.
- Programmatic hard-disable of Prefect loggers (optional/extra safety)
- If you want to be sure Prefect doesn’t emit through its named loggers, you can disable them at process start:
from prefect.logging.loggers import disable_logger, disable_run_logger
disable_run_logger() # stops run logger creation/usage
disable_logger("prefect") # disable the 'prefect' logger hierarchy
Use this only if you truly want no Prefect logs at all.
Notes
- If you run flows via a worker/deployment, set the same env vars on the worker runtime so it inherits your config.
- To avoid duplicates, keep propagate: True
on prefect
loggers in your YAML and do not attach handlers to them; let your root/app loggers handle output.
Reference showing PREFECT_LOGGING_SETTINGS_PATH
usage in 3.x: Flow gets stuck when sending logs to UI from some libraries (issue shows logging.yml + PREFECT_LOGGING_SETTINGS_PATH)
If you can share how you run flows (local script vs deployment/worker) I can tailor the exact env/config placement.Syméon del Marmol
08/31/2025, 2:43 PMPREFECT_LOGGING_SETTINGS_PATH
env variable. However it seems that I still get rich error logging coming from prefect configuration.
How can I remove that ?Marvin
08/31/2025, 2:44 PMMarvin
08/31/2025, 2:47 PMversion: 1
disable_existing_loggers: False
formatters:
standard:
format: "%(asctime)s | %(levelname)s | %(name)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: INFO
formatter: standard
stream: <ext://sys.stdout>
loggers:
prefect:
level: INFO
handlers: [console]
propagate: False
root:
level: INFO
handlers: [console]
Notes:
- Make sure you do not reference prefect.logging.handlers.PrefectConsoleHandler
or prefect.logging.formatters.PrefectFormatter
in this config.
- If anything still sneaks in from other libraries, you can set disable_existing_loggers: True
and explicitly define only the loggers you want.
If you still see “rich” tracebacks specifically (not logs):
- That’s usually CLI/console handling rather than Python’s logging. Disabling CLI colors via PREFECT_CLI_COLORS=false typically handles this.
- As a last resort in your own Python entrypoint you can restore the default excepthook:
-
import sys
sys.excepthook = sys.__excepthook__
If you can share a quick example line of the “rich error logging” you’re still seeing (colored traceback vs. colored log line), I can tailor the exact knob(s) to turn.