logging option on Stagehand.create(): a level, an output format, and a callback that receives each record. Use the language selector to see the exact shape your SDK accepts.
Quick start
Choose your logging setup based on your environment:- TypeScript
- Python
- Go
Operational logging
Real-time event logging during automation execution.Verbosity level
Control how much detail you see in logs. The level is always applied at the source, so the Stagehand runtime never generates or sends a record below your threshold. Every SDK sets that threshold the same way, and the default isinfo.
- Level: debug
- Level: info (default)
- Level: error or off
Use for: Development, debugging specific issues
- TypeScript
- Python
- Go
Example output
Example output
Log destinations
Send logs to your console or through your own callback. The record callback drives every destination, so anything your own code can write to is a valid sink. To forward records to an observability platform, see External logging platforms.- Pretty (default)
- JSON
- Custom logger
Human-readable, single-line console output written to standard error.When to use: Development and interactive debugging
- TypeScript
- Python
- Go
Output shape
Output shape
Each line is
[stagehand] LEVEL message {json data}, with the data object omitted when empty. Stagehand writes it to standard error so it never mixes with your program’s own standard output.External logging platforms
The same log callback, pointed at an observability platform. When to use: Production with Sentry, DataDog, CloudWatch, or a custom observability platform for centralized monitoring and error alerting.Sentry
1
Create a production logger
- TypeScript
- Python
- Go
2
Pass the logger in your Stagehand instance
- TypeScript
- Python
- Go
DataDog
1
Create a production logger
- TypeScript
- Python
- Go
2
Pass the logger in your Stagehand instance
- TypeScript
- Python
- Go
Failures inside your callback are caught and reported on standard error, so a failing logger will not take down your automation. That covers exceptions and rejected promises in TypeScript and Python, and a panic in Go.
File-based session logging
Route the log callback to a file to get a durable, per-session record of every Stagehand operation:act, observe, extract, LLM inference, and browser events.
Setup
Pick a directory for your session logs and open a file per run:- TypeScript
- Python
- Go
Usage
Write each record as one JSON line, then run your Stagehand script as normal:- TypeScript
- Python
- Go
Viewing logs
- Real-time monitoring
- Chronological review
- Historical sessions
Follow all logs as they happen:Or filter by category as they stream:
Log files
Because you own the sink, you decide how records are split. A common layout is one file per concern, keyed off the log category:This is especially useful for debugging long workflows where you need to trace the full sequence of LLM decisions and browser actions after the fact.
LLM inference debugging
Run at thedebug level to see the complete inference path: the snapshot that was captured, the prompt category, the model’s chosen element, and the token counts for each call.
- TypeScript
- Python
- Go
Inference request
Inference request
Emitted before each LLM call, carrying the operation and prompt metadata:
Inference response
Inference response
Emitted when the model returns, carrying the selected element:
Usage summary
Usage summary
Emitted once per operation with the token and latency accounting:
Reference
Logging configuration
Pass all logging options as a single object toStagehand.create():
- TypeScript
- Python
- Go
The level is also forwarded to the Stagehand runtime, so suppressed records are never generated or sent over the wire. Raising it to
debug increases both log volume and message traffic.Log structure
Each log entry follows a structured format:- TypeScript
- Python
- Go
Unlike v3’s
LogLine, data is a flat JSON object: values are already typed, so there is no { value, type } wrapper to parse. Fields such as category and timestamp appear inside data when the emitting operation provides them.Log examples
Log examples
- Successful action
- LLM inference
- Error
Next steps
Now that you have logging configured, explore additional debugging and monitoring tools in the Observability guide:Tracing
Export OpenTelemetry spans for every Stagehand operation to your own collector, with trace context propagated across the SDK and runtime boundary.
Metrics API
Monitor token usage and performance in real-time. Track costs per operation, identify expensive calls, and optimize resource usage.
LLM inference debugging
Run at the debug level to see exactly what Stagehand sent to the model and why the model chose each action.
Browserbase session monitoring
Watch your automation visually with session recordings, network monitoring, and real-time browser inspection (Browserbase only).

