INFO
.
PREFECT_LOGGING_[PATH]_[TO]_[KEY]=value
corresponding to the nested address of the field you are configuring.
For example, to change the default logging level for flow runs but not task runs, update your profile with:
WARNING
level logs
to the console. As with other logging settings, you can override this from the environment or in the logging configuration
file. For example, you can change the level with the PREFECT_LOGGING_ROOT_LEVEL
environment variable.
In some situations you may want to completely overhaul the Prefect logging configuration by providing your own logging.yml
file.
You can create your own version of logging.yml
in one of two ways:
logging.yml
file in your PREFECT_HOME
directory (default is ~/.prefect
).logging.yml
file using the PREFECT_LOGGING_SETTINGS_PATH
setting.logging.yml
file at the specified location, it will fall back to using the default logging configuration.
See the Python Logging configuration
documentation for more information about the configuration options and syntax used by logging.yml
.
"%(asctime)s.%(msecs)03d | %(levelname)-7s | Task run %(task_run_name)r - %(message)s"
for tasks and
similarly "%(asctime)s.%(msecs)03d | %(levelname)-7s | Flow run %(flow_run_name)r - %(message)s"
for flows.
The variables available to interpolate in log messages vary by logger.
In addition to the run context, message string,
and any keyword arguments, flow and task run loggers have access to additional variables.
The flow run logger has the following variables available for formatting:
flow_run_name
flow_run_id
flow_name
task_run_id
flow_run_id
task_run_name
task_name
flow_run_name
flow_name
logging.yml
file as
described earlier.
For example, the following changes the formatting for the flow runs formatter:
PREFECT_LOGGING_COLORS
setting:
styles
section of the Prefect logging configuration file for available keys.
my_package_or_module.py
(rename as needed) in the same directory as the flow run
script; or ideally as part of a Python package so it’s available in site-packages
and accessible anywhere within your environment.~/.prefect/logging.yml
to use my_package_or_module.CustomConsoleHandler
and additionally reference the
base_style and named expression: log.email
.my@email.com
is colored in
magenta below:PREFECT_LOGGING_MARKUP
:
DROP TABLE [dbo].[SomeTable];"
outputs
DROP TABLE .[SomeTable];
.PREFECT_LOGGING_EXTRA_LOGGERS
setting.
To use this setting, specify one or more Python library names to include,
separated by commas. For example, if you want Prefect to capture Dask
and SciPy logging statements with your flow and task run logs, use:
PREFECT_LOGGING_EXTRA_LOGGERS=dask,scipy
Configure this setting as an environment variable or in a profile. See
Settings for more details about how to use settings.