Log from your tasks and view logs in the Hatchet dashboard.
Hatchet captures log output from your task functions and surfaces it in the dashboard alongside the run that produced it. You can log using Python’s standard logging module, print, or the structured ctx.log() method. All three approaches are visible in the task run detail view.
Any output written to stdout — via print or the standard logging module — is captured by Hatchet and stored against the task run. No extra configuration is required.
Python
TypeScript
Go
The following example uses Python’s standard logging module inside a task. Hatchet intercepts the output and attaches it to the run.
ctx.log() sends a log line directly to the Hatchet API and associates it with the current task run. Unlike stdout capture, ctx.log() lines are immediately visible in the dashboard as the task runs. You can pass a plain string or any JSON-serializable mapping.
A dict or any JSON-serializable mapping — automatically serialized to JSON before sending
The call returns immediately and does not block the task. If the log write fails, it is silently dropped by default. Pass raise_on_error=True to surface errors:
The Go SDK does not expose a ctx.Log() method directly. Use stdout logging — the worker captures and forwards it to Hatchet.
Log lines sent via ctx.log() are stored in Hatchet’s database with the task run. They are separate from your application’s logging pipeline and do not appear in external log aggregators unless you also write to stdout.
The hatchet.logs client lets you retrieve log lines for any task run programmatically. This is useful for post-run analysis, surfacing logs in your own UI, or exporting to an external store.
Python
Go
from datetime import datetime, timedelta, timezonefrom hatchet_sdk import Hatchethatchet = Hatchet()# Retrieve up to 1000 log lines for a task runlogs = hatchet.logs.list(task_run_id="<task-run-id>")for line in logs.rows: print(line.created_at, line.message)
Each log line returned by logs.list includes a created_at timestamp and the message text. To correlate logs with run metadata, combine the logs API with the runs API:
Python
from hatchet_sdk import Hatchethatchet = Hatchet()# Get the task run to find its workflow runtask_run = hatchet.runs.get_task_run(task_run_id)# Fetch logs for that specific task runlogs = hatchet.logs.list(task_run_id=task_run_id)print(f"Task: {task_run.display_name}, Status: {task_run.status}")for line in logs.rows: print(f" [{line.created_at}] {line.message}")