<@ULVA73B9P> How can I disable the use of "rich" l...
# ask-marvin
s
@Marvin How can I disable the use of "rich" logging for errors that comes with prefect automatically ? It gives me tons of logs that I can't use to debug properly.
m
thought for 379.1 seconds
Totally doable. In Prefect 3.x (you’re on 3.4.14), the “rich” formatting comes from the Prefect console handler. You can either turn off the cosmetics or replace the handler entirely so errors use standard Python logging/tracebacks. Here are your options: Option A — Quick switches (disable colors/markup) - Disable colors (often the biggest culprit): - Linux/macOS:
Copy code
export PREFECT_LOGGING_COLORS=false
- Windows (PowerShell):
Copy code
$env:PREFECT_LOGGING_COLORS = "false"
- Ensure markup stays off (it’s false by default): - Linux/macOS:
Copy code
export PREFECT_LOGGING_MARKUP=false
- Windows:
Copy code
$env:PREFECT_LOGGING_MARKUP = "false"
Option B — Replace Prefect’s Rich console handler with standard logging 1) Create a logging config file (YAML) that uses the standard StreamHandler (no Rich). For example, save this as `logging.yml`:
Copy code
version: 1
disable_existing_loggers: False

formatters:
  basic:
    format: '%(asctime)s.%(msecs)03d | %(levelname)-7s | %(name)s | %(message)s'

handlers:
  console:
    class: logging.StreamHandler
    stream: <ext://sys.stdout>
    formatter: basic
    level: INFO

loggers:
  prefect:
    level: INFO
    handlers: [console]
    propagate: no

root:
  level: WARNING
  handlers: [console]
2) Tell Prefect to use it: - EITHER put it at Prefect’s default location (Prefect will auto-discover a
logging.yml
under your Prefect home; this is often the simplest path) - OR point Prefect at your file via settings: - Environment variable
Copy code
export PREFECT_LOGGING__CONFIG_PATH=/absolute/path/to/logging.yml
(Windows PowerShell)
Copy code
$env:PREFECT_LOGGING__CONFIG_PATH = "C:\path\to\logging.yml"
- Or set the [logging].config_path in your Prefect profile. This fully replaces the PrefectConsoleHandler (Rich) with a plain StreamHandler so exceptions and errors are standard and much less noisy. Optional noise reductions - Raise the root level to WARNING (as in the YAML above) to hide info-level chatter - Disable sending logs to the API if you don’t need it:
Copy code
export PREFECT_LOGGING_TO_API__ENABLED=false
Docs for reference - Logging customization: Logging customization - Settings reference (all logging settings): Settings reference If you share how you’re running (local scripts, worker pods, etc.), I can suggest the most direct way to apply this in your environment.