logging module has the following structure:
AgentListener listens to an HTTP endpoint, while an AgentLogger defines the logging behaviour itself e.g. printing and file logging. Think of listeners as the “when” and “where” of logging, while loggers are the “what” and the “how”.
Specifying logging behaviour
Agentica provides three ways to specify how agents and agentic functions are logged, each with different scopes and priorities. Understanding the hierarchy helps you control logging behavior precisely for your use case.Listener priority hierarchy
When an agent or agentic function is invoked, listener resolution follows this priority (highest to lowest):- Contextual loggers (via context manager) - highest priority, temporary
- Per-agent/agentic function listener (via
listenerparameter) - medium priority, per-instance - Default agent listener (via
set_default_agent_listener) - lowest priority, global
CompositeLogger that routes events to all loggers simultaneously.
Method 1: Default listener (global)
The default agent listener for all agents and agentic functions is theStandardListener. You can change this globally with set_default_agent_listener.
Method 2: Per-agent/agentic function listener
Override the default for specific agents or agentic functions:Method 3: Contextual loggers (scoped)
Use anyAgentLogger to temporarily control logging for all agents and agentic functions spawned and invoked within that scope:
This is particularly useful for temporarily changing logging behavior for a specific section of code - for example, to debug a particular workflow or to separate logs for different operations.
NoLogging:
Built-in listeners and loggers
Agentica offers built-in listeners and loggers with various combinations of behaviour, notably printing tostdout and writing to .log files.
| Logger | Listener | stdout | .log |
|---|---|---|---|
StandardLogger | StandardListener | ||
PrintLogger | PrintOnlyListener | ||
FileLogger | FileOnlyListener | ||
NoLogging | |||
CaptionLogger | |||
StreamLogger |
.log files include
- writing full chat histories to per‑agent files under
./logs/(e.g.,agent-7.log), - allocates incrementing agent IDs based on existing files, and
- auto‑creating the logs directory (with a
.gitignore).
stdout includes
- assigning stable colors per agent,
- printing on spawning an agent, and
- printing the result of an invocation an agent or an agentic function.