Application Logging¶
Overview¶
This directory contains the logging configuration for the FastAPI application. The logging system is based on structured JSON logging with ELK stack integration.
Components¶
- Logstash: Collects and processes logs
- Elasticsearch: Stores and indexes logs
- Kibana: Visualizes logs and provides dashboards
- Filebeat: Ships logs from the application to Logstash
Log Levels¶
The following log levels are used:
- DEBUG: Detailed information for debugging
- INFO: General information about application operation
- WARNING: Potential issues that don't prevent the application from working
- ERROR: Errors that prevent specific operations from working
- CRITICAL: Critical errors that prevent the application from working
Log Format¶
Logs are formatted as JSON with the following fields:
timestamp: ISO 8601 timestamplevel: Log levelmessage: Log messagelogger: Logger namerequest_id: Unique request identifieruser_id: User identifier (if authenticated)path: Request pathmethod: HTTP methodstatus_code: HTTP status codeduration_ms: Request duration in millisecondsexception: Exception details (if applicable)
Setup¶
The logging system is automatically set up when you run:
make logging-up
Accessing Logs¶
Once the logging system is running, you can access the logs at:
- Kibana:
http://localhost:5601
Configuration¶
The logging configuration can be customized by editing the following files:
logstash/pipeline/*.conf: Logstash pipeline configurationelasticsearch/config/*.yml: Elasticsearch configurationkibana/config/*.yml: Kibana configurationfilebeat/filebeat.yml: Filebeat configuration
Integration with Monitoring¶
The logging system is integrated with the monitoring system. Metrics about log volume and errors are available in the monitoring dashboards.