How can I adjust log settings such as the default log level or logging format?

To change the default log settings, use the following environment variable format:

prefect config set PREFECT_LOGGING_LEVEL=DEBUG
export PREFECT_LOGGING_DEFAULT_FORMAT="%(levelname)s - %(name)s | %(message)s"

You can specify custom formatting by:

You can also set a custom format for flow run or task run logs. The variables available to interpolate in log messages vary by the type of logger. Here is an example setting a custom format for flow run logs:

export PREFECT_LOGGING_FORMATTERS_FLOW_RUNS_FORMAT="%(asctime)s.%(msecs)03d | %(levelname)-7s | %(flow_run_id)s - %(message)s"

The resulting messages, using the flow run ID instead of name, would look like this:

10:40:01.211 | INFO    | e43a5a80-417a-41c4-a39e-2ef7421ee1fc - Created task run 
'othertask-1c085beb-3' for task 'othertask'

For more information related to logging settings, see:


Prefect 1.0

Prefect 1.0 works works similarly but it uses a slightly different syntax:

export PREFECT__LOGGING__LEVEL=DEBUG
export PREFECT__LOGGING__FORMAT="%(levelname)s - %(name)s | %(message)s"
1 Like