Observability Logging
Comprehensive logging system for RecoAgent applications with structured logging and log aggregation.
Overview
The observability logging system provides structured logging, log aggregation, and log analysis capabilities for monitoring and debugging RecoAgent applications.
Core Features
- Structured Logging: JSON-formatted logs with metadata
- Log Levels: Configurable log levels and filtering
- Log Aggregation: Centralized log collection and storage
- Log Analysis: Search and analysis capabilities
- Integration: Integration with external logging systems
Usage Examples
Basic Logging Setup
from recoagent.observability.logging import LoggerManager
# Create logger manager
logger_manager = LoggerManager()
# Get logger
logger = logger_manager.get_logger("recoagent.app")
# Log messages
logger.info("Application started", extra={"version": "1.0.0"})
logger.warning("High memory usage detected", extra={"memory_usage": 0.85})
logger.error("Database connection failed", extra={"error": str(e)})
Advanced Logging
# Create structured logger
structured_logger = logger_manager.create_structured_logger(
name="recoagent.analytics",
format="json",
level="INFO"
)
# Log structured data
structured_logger.info("Query processed", {
"query_id": "q123",
"user_id": "u456",
"processing_time": 1.5,
"result_count": 10
})
API Reference
LoggerManager Methods
get_logger(name: str) -> Logger
Get logger instance
Parameters:
name(str): Logger name
Returns: Logger instance
create_structured_logger(name: str, format: str, level: str) -> StructuredLogger
Create structured logger
Parameters:
name(str): Logger nameformat(str): Log formatlevel(str): Log level
Returns: StructuredLogger instance
See Also
- Observability Tracing - Distributed tracing
- Observability Metrics - Metrics collection