🐳 Docker Compose Logs Guide¶
📋 Overview¶
This guide explains how to view and configure logs when running the Mail Archiver application using Docker Compose. Proper log management is essential for monitoring application health, troubleshooting issues, and understanding system behavior.
📖 Viewing Docker Compose Logs¶
Basic Log Commands¶
To view logs from all services in your Docker Compose setup:
To view logs for a specific service (e.g., the Mail Archiver application):
Real-time Log Streaming¶
To follow logs in real-time (similar to tail -f):
To follow logs for a specific service:
Log Filtering and Options¶
Show last N lines of logs:
Show logs since a specific time:
Show logs until a specific time:
Show timestamps in logs:
📝 Log Level Configuration¶
The Mail Archiver application supports various log levels that control the verbosity of the output. You can configure these levels using environment variables in your docker-compose.yml file.
Available Log Levels¶
The following log levels are available, ordered from most verbose to least verbose:
Trace- Most detailed logging, including internal framework messagesDebug- Detailed debugging information for development and troubleshootingInformation- General information about application flow (default level)Warning- Warning messages about potential issuesError- Error messages about failed operationsCritical- Critical error messages that require immediate attentionNone- No logging output
Default Log Configuration¶
By default, the application uses the following log level configuration:
- Default: Information
- Microsoft.AspNetCore: Warning (reduces framework noise)
- Microsoft.EntityFrameworkCore.Database.Command: Warning (reduces database command noise)
Configuring Log Levels in Docker Compose¶
To customize log levels, add the following environment variables to your docker-compose.yml file under the mailarchive-app service:
services:
mailarchive-app:
image: s1t5/mailarchiver:latest
environment:
# Other environment variables...
# Logging Settings (Optional)
- Logging__LogLevel__Default=Information
- Logging__LogLevel__Microsoft_AspNetCore=Warning
- Logging__LogLevel__Microsoft_EntityFrameworkCore_Database_Command=Warning
Example: Debug Configuration¶
For troubleshooting purposes, you might want to enable more verbose logging:
services:
mailarchive-app:
image: s1t5/mailarchiver:latest
environment:
# Other environment variables...
# Verbose Logging for Debugging
- Logging__LogLevel__Default=Debug
- Logging__LogLevel__Microsoft_AspNetCore=Information
- Logging__LogLevel__Microsoft_EntityFrameworkCore_Database_Command=Debug
Example: Production Configuration¶
For production environments, you might want to reduce log verbosity to improve performance and reduce log volume:
services:
mailarchive-app:
image: s1t5/mailarchiver:latest
environment:
# Other environment variables...
# Production Logging (Reduced Verbosity)
- Logging__LogLevel__Default=Warning
- Logging__LogLevel__Microsoft_AspNetCore=Error
- Logging__LogLevel__Microsoft_EntityFrameworkCore_Database_Command=Error
🔍 Understanding Log Output¶
Log Format¶
Logs follow this general format:
Example:
2025-01-15T10:30:45.123Z [Information] MailArchiver.Services.EmailService - Starting email synchronization for account user@example.com
Common Log Categories¶
MailArchiver.Services.*- Application service logsMailArchiver.Controllers.*- Web API controller logsMicrosoft.AspNetCore- ASP.NET Core framework logsMicrosoft.EntityFrameworkCore- Entity Framework logsMicrosoft.Extensions.Hosting- Hosting-related logs
🛠️ Troubleshooting Tips¶
1. Finding Error Messages¶
To quickly find error messages in the logs:
2. Monitoring Specific Operations¶
To monitor email synchronization:
3. Checking for Warnings¶
To check for warning messages:
📊 Log Management Best Practices¶
For Development¶
- Use
DebugorInformationlevel for detailed troubleshooting - Enable real-time log streaming during development
- Monitor logs continuously while testing new features
For Production¶
- Use
WarningorErrorlevel to reduce log volume - Implement log rotation to prevent disk space issues
- Consider centralized logging solutions for multi-container setups
- Regularly review logs for security events and performance issues
📚 Related Documentation¶
- Installation and Setup Guide - Complete setup instructions
- Access Logging - Application-level access logging
- Backup and Restore Guide - Data protection procedures