As of Prefect 2.6.9, all console handlers are unified into a single console handler with Rich formatting:
handlers:
# The handlers we define here will output all logs they receieve by default
# but we include the `level` so it can be overridden by environment
console:
level: 0
class: prefect.logging.handlers.PrefectConsoleHandler
formatter: standard
styles:
log.web_url: bright_blue
log.local_url: bright_blue
log.info_level: cyan
log.warning_level: yellow3
log.error_level: red3
log.critical_level: bright_red
log.completed_state: green
log.cancelled_state: yellow3
log.failed_state: red3
log.crashed_state: bright_red
log.flow_run_name: magenta
log.flow_name: bold magenta
This makes it quick and easy to make Prefect’s output look exactly the way you want (See the Rich docs for more information on available styles). If you want to get started with log customization, the easiest way is to use a custom logging.yml
file like Khuyen mentioned above.
Prefect’s default logging.yml file makes a great starting point. Make a copy of it and then customize it any way you’d like!
To get Prefect to use your custom logging.yml
automatically, place a copy of it in your Prefect home directory. This will vary depending on your operating system:
-
/home/<your username>/.prefect
on Linux -
/Users/<your username>/.prefect
on MacOS -
C:\Users\<your username>\.prefect
on Windows
Alternatively, you can keep your logging configuration elsewhere and run the following to tell Prefect where to look for logging configuration:
prefect config set PREFECT_LOGGING_SETTINGS_PATH=/path/to/your/logging.yml
Either way, next time you run a Prefect flow, it will use your custom logging configuration!