Loggers
Built-in loggers
- dagster._loggers.colored_console_logger [source]
- Core class for defining loggers. - Loggers are job-scoped logging handlers, which will be automatically invoked whenever dagster messages are logged from within a job. - Parameters: - logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on context.logare called from within job compute logic.
- config_schema (Optional[ConfigSchema]) – The schema for the config. Configuration data available in init_context.logger_config. If not set, Dagster will accept any config provided.
- description (Optional[str]) – A human-readable description of this logger.
 
- logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on 
- dagster._loggers.json_console_logger [source]
- Core class for defining loggers. - Loggers are job-scoped logging handlers, which will be automatically invoked whenever dagster messages are logged from within a job. - Parameters: - logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on context.logare called from within job compute logic.
- config_schema (Optional[ConfigSchema]) – The schema for the config. Configuration data available in init_context.logger_config. If not set, Dagster will accept any config provided.
- description (Optional[str]) – A human-readable description of this logger.
 
- logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on 
Logging from an @op
- classdagster.DagsterLogManager [source]
- Centralized dispatch for logging from user code. - Handles the construction of uniform structured log messages and passes them through to the underlying loggers/handlers. - An instance of the log manager is made available to ops as - context.log. Users should not initialize instances of the log manager directly. To configure custom loggers, set the- logger_defsargument in an @job decorator or when calling the to_job() method on a- GraphDefinition.- The log manager inherits standard convenience methods like those exposed by the Python standard library - python:loggingmodule (i.e., within the body of an op,- context.log.\{debug, info, warning, warn, error, critical, fatal}).- The underlying integer API can also be called directly using, e.g. - context.log.log(5, msg), and the log manager will delegate to the- logmethod defined on each of the loggers it manages.- User-defined custom log levels are not supported, and calls to, e.g., - context.log.traceor- context.log.noticewill result in hard exceptions at runtime.
Defining custom loggers
- @dagster.logger [source]
- Define a logger. - The decorated function should accept an - InitLoggerContextand return an instance of- python:logging.Logger. This function will become the- logger_fnof an underlying- LoggerDefinition.- Parameters: - config_schema (Optional[ConfigSchema]) – The schema for the config. Configuration data available in init_context.logger_config. If not set, Dagster will accept any config provided.
- description (Optional[str]) – A human-readable description of the logger.
 
- classdagster.LoggerDefinition [source]
- Core class for defining loggers. - Loggers are job-scoped logging handlers, which will be automatically invoked whenever dagster messages are logged from within a job. - Parameters: - logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on context.logare called from within job compute logic.
- config_schema (Optional[ConfigSchema]) – The schema for the config. Configuration data available in init_context.logger_config. If not set, Dagster will accept any config provided.
- description (Optional[str]) – A human-readable description of this logger.
 - propertyconfig_schema [source]
- The schema for the logger’s config. Configuration data available in init_context.logger_config. - Type: Any 
 - propertydescription [source]
- A human-readable description of the logger. - Type: Optional[str] 
 - propertylogger_fn [source]
- The function that will be invoked to instantiate the logger. - Type: Callable[[InitLoggerContext], logging.Logger] 
 
- logger_fn (Callable[[InitLoggerContext], logging.Logger]) – User-provided function to instantiate the logger. This logger will be automatically invoked whenever the methods on 
- classdagster.InitLoggerContext [source]
- The context object available as the argument to the initialization function of a - dagster.LoggerDefinition.- Users should not instantiate this object directly. To construct an InitLoggerContext for testing purposes, use - dagster. build_init_logger_context().- Example: - from dagster import logger, InitLoggerContext
 @logger
 def hello_world(init_context: InitLoggerContext):
 ...- propertylogger_config [source]
- The configuration data provided by the run config. The schema for this data is defined by - config_schemaon the- LoggerDefinition.
 - propertylogger_def [source]
- The logger definition for the logger being constructed. 
 - propertyrun_id [source]
- The ID for this run of the job. 
 
- dagster.build_init_logger_context [source]
- Builds logger initialization context from provided parameters. - This function can be used to provide the context argument to the invocation of a logger definition. - Note that you may only specify one of pipeline_def and job_def. - Parameters: - logger_config (Any) – The config to provide during initialization of logger.
- job_def (Optional[JobDefinition]) – The job definition that the logger will be used with.
 - Examples: - context = build_init_logger_context()
 logger_to_init(context)