Skip to content

Debugging#

AG2 Event Logging: Standardized Observability with Python Logging

AG2 Event Logging

AG2 now integrates with Python's standard logging module for event output, giving you full control over how agent events are captured, formatted, and processed. This integration brings enterprise-grade observability directly into your agent workflows.

This article explores how to configure and customize AG2 event logging, with practical examples for testing, monitoring, and production deployments.

{/ more /}

What is AG2 Event Logging?

AG2 event logging provides a standardized way to capture and process events from agent interactions. All event output flows through the ag2.event.processor logger, which uses Python's standard logging module under the hood.

Key Features:

  • Standard Python Logging: Leverages the familiar logging module you already know
  • Centralized Configuration: Configure once at application startup, affects all AG2 components
  • Flexible Handlers: Use any Python logging handler (file, stream, HTTP, database, etc.)
  • Custom Formatters: Structure output as JSON, plain text, or any custom format
  • Powerful Filters: Selectively log events based on content, level, or custom criteria
  • Backwards Compatible: Default behavior unchanged if no custom configuration is provided

Why This Matters:

Traditional logging approaches often require custom integration code for each component. AG2's event logging provides a unified interface that works consistently across all agent types, conversation patterns, and execution modes. Whether you're debugging a single-agent workflow or monitoring a complex multi-agent system, the same logging configuration applies.

When to Use Custom Event Logging:

Use custom event logging when you need: - Testing and Validation: Capture event output to verify agent behavior in automated tests - Production Monitoring: Send events to monitoring systems, log aggregation services, or databases - Debugging: Filter and format events to focus on specific issues or agent interactions - Compliance and Auditing: Maintain detailed logs of agent decisions and actions - Performance Analysis: Track event timing and frequency for optimization

Don't use custom logging for simple development workflows—the default console output is sufficient for that.