Logging¶
This section explains how logging works , where logs go , what gets logged , and how to debug production issues safely in Replimatic.
1. Logging Philosophy¶
Replimatic follows these principles:
- Application-level logging first (Django + Celery)
- Structured, readable logs (timestamps, level, source, line number)
- File-based logs inside container
- Docker handles rotation at infra level
- No sensitive data logged
- Errors are always logged with traceback
2. Logging Layers Overview¶
| Layer | Purpose |
|---|---|
| Django Logging | Business logic, requests, errors |
| Celery Logging | Background jobs, retries, failures |
| Payment Logs | Payment success/failure tracking |
| Support Logs | Support workflow visibility |
| Infrastructure Logs | Container & Nginx level |
3. Django Logging Configuration¶
Defined in:
replimatic/settings/base.py
Active Loggers¶
- root logger → captures most logs
- celery logger → Celery-specific logs
Log Format¶
[2026-01-05 12:30:22] INFO users.views 134 Profile updated
Includes:
- Timestamp
- Log level
- Module name
- Line number
- Message
4. Log Handlers¶
4.1 Main Application Log¶
File
logs/django.log
Purpose
- Request lifecycle
- Business logic logs
- Celery info logs
- Payment processing logs
Rotation
- Max size: 5 MB
- Backup files: 3
- Old logs auto-rotated
4.2 Error Log¶
File
logs/errors.log
Purpose
- Unhandled exceptions
- Payment failures
- Webhook verification failures
- Celery task crashes
Rotation
- Max size: 5 MB
- Backup files: 4
5. What Is Logged (By Category)¶
5.1 Authentication & User Actions¶
Logged:
- Login attempts (success/failure)
- Password changes
- Email verification events
Not logged:
- Passwords
- Tokens
- OAuth secrets
5.2 Payments (Critical)¶
Logged events:
- Order creation
- Payment success
- Payment failure
- Webhook verification failure
- Refund processing
Example:
This is intentionally verbose to help with financial audits.
5.3 Support System¶
Logged:
- Support request creation
- Status transitions
- Telegram notification failures
Why:
Support workflows are multi-step and asynchronous , so logs act as an audit trail.
5.4 Celery Tasks¶
Logged:
- Task start
- Retry attempts
- Final success/failure
Examples:
- Database backup task
- Email sending task
- Telegram notification task
Retries are automatically logged by Celery.
6. Celery Logging Behavior¶
Celery uses the same logging system as Django.
Worker Logs¶
make prod-celery-logs
Beat Logs¶
make prod-celery-beat-logs
Celery respects:
CELERY_WORKER_HIJACK_ROOT_LOGGER = False
This prevents Celery from breaking Django log formatting.
7. Docker & Log Access¶
View Django logs¶
make prod-logs
View container logs directly¶
docker logs replimatic_app
Tail error logs¶
docker exec -it replimatic_app tail -f logs/errors.log
8. Nginx Logging¶
Handled outside Django .
Default:
/var/log/nginx/access.log
/var/log/nginx/error.log
Used for:
- Traffic analysis
- SSL issues
- Proxy failures
Application errors do NOT rely on Nginx logs .
9. What Is Intentionally NOT Logged¶
For security & compliance:
- Passwords
- OAuth tokens
- Payment card details
- API secrets
- Session cookies
- Raw webhook payloads
Only metadata is logged.
10. Production Debugging Workflow¶
Scenario: Payment Failed¶
- Check
errors.log - Check webhook logs
- Check Celery worker logs
- Verify provider dashboard
Scenario: Background task not running¶
- Check Celery worker container
- Check Redis connectivity
- Check
errors.log - Check retry exhaustion
Scenario: File download broken¶
- Check S3 signed URL generation logs
- Verify bucket permissions
- Check
settings.DEBUG
11. Log Retention Strategy¶
Current:
- File rotation inside container
- Docker handles container lifecycle
Recommended for scale:
- Ship logs to external service (optional)
- Centralized log aggregation
Not required for MVP / early SaaS.
12. Safe Logging Guidelines (For Customization)¶
When adding logs:
logger.info("Meaningful message", extra={...})
Never:
logger.info(user.password)
Always:
- Log intent
- Log identifiers (IDs)
- Log failures with traceback
13. Logging Summary¶
| Area | Status |
|---|---|
| Django logs | ✅ Enabled |
| Error logs | ✅ Separate |
| Celery logs | ✅ Integrated |
| Rotation | ✅ Enabled |
| Sensitive data | ❌ Not logged |
| Production ready | ✅ Yes |