# Logging


Utility functions for interacting with and configuring logging. The main entrypoint for retrieving loggers for customization is the get_logger utility.

Note that Prefect Tasks come equipped with their own loggers. These can be accessed via: - self.logger if implementing a Task class - prefect.context.get("logger") if using the task decorator

When running locally, log levels and message formatting are set via your Prefect configuration file.

# Functions

top-level functions:                                                                                                                                                       

prefect.utilities.logging.configure_logging

(testing=False)[source]

Creates a "prefect" root logger with a StreamHandler that has level and formatting set from prefect.config.

Args:

  • testing (bool, optional): a boolean specifying whether this configuration is for testing purposes only; this helps us isolate any global state during testing by configuring a "prefect-test-logger" instead of the standard "prefect" logger
Returns:
  • logging.Logger: a configured logging object

prefect.utilities.logging.get_logger

(name=None)[source]

Returns a "prefect" logger.

Args:

  • name (str): if None, the root Prefect logger is returned. If provided, a child logger of the name "prefect.{name}" is returned. The child logger inherits the root logger's settings.
Returns:
  • logging.Logger: a configured logging object with the appropriate name

This documentation was auto-generated from commit n/a
on February 23, 2022 at 19:26 UTC