Issue Resolved
Issue #16 closed: Best Practices: Laravel Log Management and Deployment Cleanup on Coolify
Background
After troubleshooting a severe disk usage issue (81% disk usage, 30GB log file from 288,630 errors over 10 months), we've identified critical best practices for Laravel apps deployed on Coolify.
Recommended Best Practices
๐ Log Configuration for New Laravel Apps
When deploying Laravel applications on Coolify, always configure these environment variables:
LOG_STACK=daily
LOG_DAILY_MAX_FILES=7
CACHE_STORE=redis # NOT database
Why:
LOG_STACK=dailycreates daily log files instead of a single ever-growing fileLOG_DAILY_MAX_FILES=7automatically deletes logs older than 7 daysCACHE_STORE=redisprevents stale database references and improves performance
๐งน Regular Maintenance
Monthly Tasks:
- Review and remove old deployments in Coolify UI
- Old deployment images accumulate and can consume significant disk space
- Coolify keeps previous deployment images unless manually removed
- Check: Applications โ Deployments โ Delete old deployments
What we found:
- 85% of Docker images were unused old deployments
- Build cache accumulated to 1.75GB
- Old deployment images totaled 12GB+
๐ Monitoring
Consider adding:
- Automated log rotation scripts for emergency cleanup
- Monitoring for log files exceeding size thresholds
- Regular
docker system pruneschedules
Feature Requests
For Coolify Platform
-
Default Laravel Environment Variables
- Pre-populate
LOG_STACK=dailyandLOG_DAILY_MAX_FILES=7for Laravel apps - Warn when
CACHE_STORE=databaseis detected
- Pre-populate
-
Deployment Cleanup
- Add option to auto-delete deployments older than N days
- Show deployment disk usage in UI
- One-click cleanup for old deployment images
-
Log Management
- Built-in log rotation for application containers
- Alert when application logs exceed size threshold
- Log size monitoring in application metrics
References
This issue documents lessons learned from a production incident where:
- Single
laravel.logfile grew to 30GB - Server reached 81% disk usage
- 288,630 database connection errors logged over 10 months
- Issue went unnoticed due to lack of application-level log monitoring
Action Items
- Document these best practices in README/docs
- Create deployment template with recommended settings
- Add pre-deployment checklist
- Consider Coolify feature requests for auto-cleanup
Impact: Following these practices can prevent critical disk space issues and improve application performance.