Quick Answer
Large app logging: use logging.getLogger(__name__) in each module (hierarchical). Configure root logger once at startup. Structured logging with python-json-logger for machine-readable output. Handlers: RotatingFileHandler (size-based rotation), TimedRotatingFileHandler (daily rotation). Send to centralized logging: ELK, Datadog, CloudWatch. Add request context (user, trace ID) using logging.Filter.
Answer
Use structured logging with context. Supports file, console, and remote handlers. Enhances monitoring and traceability in production.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.