We use cookies

We use cookies and similar technologies for analytics and marketing. You can allow these cookies or continue with only essential cookies.

By clicking "Accept", you agree to our use of cookies.
Learn more.

Logging

Hatchet comes with a built-in logging view where you can push logs from your workflows. This is useful for debugging and monitoring your workflows.

You can use either Python's built-in logging package, or the context.log method for more control over the logs that are sent.

Using the built-in logging package

You can pass a custom logger to the Hatchet class when initializing it. For example:

import loggingfrom hatchet_sdk import ClientConfig, Hatchetlogging.basicConfig(level=logging.INFO)root_logger = logging.getLogger()hatchet = Hatchet(    config=ClientConfig(        logger=root_logger,    ),)

It's recommended that you pass the root logger to the Hatchet class, as this will ensure that all logs are captured by the Hatchet logger. If you have workflows defined in multiple files, they should be children of the root logger. For example, with the following file structure:

client.py
worker.py
workflow.py

You should pass the root logger to the Hatchet class in client.py:

import loggingfrom hatchet_sdk import ClientConfig, Hatchetlogging.basicConfig(level=logging.INFO)root_logger = logging.getLogger()hatchet = Hatchet(    config=ClientConfig(        logger=root_logger,    ),)

And then in workflows/workflow.py, you should create a child logger:

import loggingimport timefrom examples.logger.client import hatchetfrom hatchet_sdk import Context, EmptyModellogger = logging.getLogger(__name__)logging_workflow = hatchet.workflow(    name="LoggingWorkflow",)@logging_workflow.task()def root_logger(input: EmptyModel, ctx: Context) -> dict[str, str]:    for i in range(12):        logger.info(f"executed step1 - {i}")        logger.info({"step1": "step1"})        time.sleep(0.1)    return {"status": "success"}

Using the context.log method

You can also use the context.log method to log messages from your workflows. This method is available on the Context object that is passed to each task in your workflow. For example:

@logging_workflow.task()def context_logger(input: EmptyModel, ctx: Context) -> dict[str, str]:    for i in range(12):        ctx.log(f"executed step1 - {i}")        ctx.log({"step1": "step1"})        time.sleep(0.1)    return {"status": "success"}

Each task is currently limited to 1000 log lines.

Last updated on August 11, 2026

On this page