LogoLogo
ProductResourcesGitHubStart free
  • Documentation
  • Learn
  • ZenML Pro
  • Stacks
  • API Reference
  • SDK Reference
  • Getting Started
    • Welcome to ZenML
    • Installation
    • Hello World
    • Core Concepts
    • System Architecture
  • Deploying ZenML
    • Deploy
      • Deploy with Docker
      • Deploy with Helm
      • Deploy using HuggingFace Spaces
      • Deploy with custom images
      • Secret management
      • Custom secret stores
    • Connect
      • with your User (interactive)
      • with an API Token
      • with a Service Account
    • Manage
      • Best practices for upgrading
      • Using ZenML server in production
      • Troubleshoot your ZenML server
      • Migration guide
        • Migration guide 0.13.2 → 0.20.0
        • Migration guide 0.23.0 → 0.30.0
        • Migration guide 0.39.1 → 0.41.0
        • Migration guide 0.58.2 → 0.60.0
  • Concepts
    • Steps & Pipelines
      • Configuration
      • Scheduling
      • Logging
      • Advanced Features
      • YAML Configuration
    • Artifacts
      • Materializers
      • Visualizations
    • Stack & Components
    • Service Connectors
    • Containerization
    • Code Repositories
    • Secrets
    • Tags
    • Metadata
    • Models
    • Templates
    • Dashboard
  • Reference
    • Community & content
    • Environment Variables
    • llms.txt
    • FAQ
    • Global settings
    • Legacy docs
Powered by GitBook
On this page
  • Logging Configuration
  • Environment Variables and Remote Execution
  • Enabling or Disabling Logs Storage
  • Setting Logging Verbosity
  • Setting Logging Format
  • Disabling Rich Traceback Output
  • Disabling Colorful Logging
  • Disabling Step Names in Logs
  • Best Practices for Logging
  • See Also

Was this helpful?

Edit on GitHub
  1. Concepts
  2. Steps & Pipelines

Logging

Learn how to control and customize logging behavior in ZenML pipelines.

PreviousSchedulingNextAdvanced Features

Last updated 12 days ago

Was this helpful?

By default, ZenML uses a logging handler to capture two types of logs:

  • Pipeline run logs: Logs collected from your ZenML client while triggering and waiting for a pipeline to run. These logs cover everything that happens client-side: building and pushing container images, triggering the pipeline, waiting for it to start, and waiting for it to finish. These logs are now stored in the artifact store, making them accessible even after the client session ends.

  • Step logs: Logs collected from the execution of individual steps. These logs only cover what happens during the execution of a single step and originate mostly from the user-provided step code and the libraries it calls.

For step logs, users are free to use the default python logging module or print statements, and ZenML's logging handler will catch these logs and store them.

import logging

from zenml import step

@step 
def my_step() -> None:
    logging.warning("`Hello`")  # You can use the regular `logging` module.
    print("World.")  # You can utilize `print` statements as well. 

All these logs are stored within the respective artifact store of your stack. You can visualize the pipeline run logs and step logs in the dashboard as follows:

  • Local ZenML server (zenml login --local): Both local and remote artifact stores may be accessible

  • Deployed ZenML server: Local artifact store logs won't be accessible; remote artifact store logs require configuration (see )

In order for logs to be visible in the dashboard with a deployed ZenML server, you must configure both a remote artifact store and the appropriate service connector to access it. Without this configuration, your logs won't be accessible through the dashboard.

Logging Configuration

Environment Variables and Remote Execution

For all logging configurations below, note:

  • Setting environment variables on your local machine only affects local pipeline runs

  • For remote pipeline runs, you must set these variables in the pipeline's execution environment using Docker settings:

from zenml import pipeline
from zenml.config import DockerSettings

docker_settings = DockerSettings(environment={"ENVIRONMENT_VARIABLE": "value"})

# Either add it to the decorator
@pipeline(settings={"docker": docker_settings})
def my_pipeline() -> None:
    my_step()

# Or configure the pipelines options
my_pipeline = my_pipeline.with_options(
    settings={"docker": docker_settings}
)

Enabling or Disabling Logs Storage

You can control log storage for both pipeline runs and steps:

Step Logs

To disable storing step logs in your artifact store:

  1. Using the enable_step_logs parameter with step decorator:

    from zenml import step
    
    @step(enable_step_logs=False)  # disables logging for this step
    def my_step() -> None:
        ...
  2. Setting the ZENML_DISABLE_STEP_LOGS_STORAGE=true environment variable in the execution environment:

    from zenml import pipeline
    from zenml.config import DockerSettings
    
    docker_settings = DockerSettings(environment={"ZENML_DISABLE_STEP_LOGS_STORAGE": "true"})
    
    # Either add it to the decorator
    @pipeline(settings={"docker": docker_settings})
    def my_pipeline() -> None:
        my_step()
    
    # Or configure the pipelines options
    my_pipeline = my_pipeline.with_options(
        settings={"docker": docker_settings}
    )

    This environment variable takes precedence over the parameter mentioned above.

Pipeline Run Logs

To disable storing client-side pipeline run logs in your artifact store:

  1. Using the enable_pipeline_logs parameter with pipeline decorator:

    from zenml import pipeline
    
    @pipeline(enable_pipeline_logs=False)  # disables client-side logging for this pipeline
    def my_pipeline():
        ...
  2. Using the runtime configuration:

    # Disable pipeline logs at runtime
    my_pipeline.with_options(enable_pipeline_logs=False)
  3. Setting the ZENML_DISABLE_PIPELINE_LOGS_STORAGE=true environment variable:

    from zenml import pipeline
    from zenml.config import DockerSettings
    
    docker_settings = DockerSettings(environment={"ZENML_DISABLE_PIPELINE_LOGS_STORAGE": "true"})
    
    # Either add it to the decorator
    @pipeline(settings={"docker": docker_settings})
    def my_pipeline() -> None:
        my_step()
    
    # Or configure the pipelines options
    my_pipeline = my_pipeline.with_options(
        settings={"docker": docker_settings}
    )

    The environment variable takes precedence over parameters set in the decorator or runtime configuration.

Setting Logging Verbosity

Change the default logging level (INFO) with:

export ZENML_LOGGING_VERBOSITY=INFO

Options: INFO, WARN, ERROR, CRITICAL, DEBUG

For remote pipeline runs:

from zenml import pipeline
from zenml.config import DockerSettings

docker_settings = DockerSettings(environment={"ZENML_LOGGING_VERBOSITY": "DEBUG"})

# Either add it to the decorator
@pipeline(settings={"docker": docker_settings})
def my_pipeline() -> None:
    my_step()

# Or configure the pipelines options
my_pipeline = my_pipeline.with_options(
    settings={"docker": docker_settings}
)

Setting Logging Format

Change the default logging format with:

export ZENML_LOGGING_FORMAT='%(asctime)s %(message)s'

Disabling Rich Traceback Output

export ZENML_ENABLE_RICH_TRACEBACK=false

Disabling Colorful Logging

Disable colorful logging with:

ZENML_LOGGING_COLORS_DISABLED=true

Disabling Step Names in Logs

By default, ZenML adds step name prefixes to console logs:

[data_loader] Loading data from source...
[data_loader] Data loaded successfully.
[model_trainer] Training model with parameters...

These prefixes only appear in console output, not in stored logs. Disable them with:

ZENML_DISABLE_STEP_NAMES_IN_LOGS=true

Best Practices for Logging

  1. Use appropriate log levels:

    • DEBUG: Detailed diagnostic information

    • INFO: Confirmation that things work as expected

    • WARNING: Something unexpected happened

    • ERROR: A more serious problem occurred

    • CRITICAL: A serious error that may prevent continued execution

  2. Include contextual information in logs

  3. Log at decision points to track execution flow

  4. Avoid logging sensitive information

  5. Use structured logging when appropriate

  6. Configure appropriate verbosity for different environments

See Also

The format must use %-string formatting style. See .

ZenML uses for enhanced traceback display. Disable it with:

available attributes
rich
Steps & Pipelines
YAML Configuration
Advanced Features
service connector
remote storage guide
Displaying pipeline run logs on the dashboard
Displaying step logs on the dashboard