mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 07:52:54 +00:00
Fix Django logging configuration for Docker containers
## Issue Fixed: - Django production logging was trying to write to `/var/log/django/django.log` - This directory doesn't exist in Docker containers, causing deployment failures - Error: `FileNotFoundError: [Errno 2] No such file or directory: '/var/log/django/django.log'` ## Solution: - **Modified production.py**: Switched from file-based to console-only logging - **Docker-friendly logging**: All logs now go to stdout/stderr for container compatibility - **Dokploy integration**: Logs are now visible in Dokploy's log viewer - **Added troubleshooting**: Updated DOKPLOY.md with this specific error and solution ## Benefits: - ✅ Works seamlessly with Docker containers - ✅ Integrates with Dokploy log viewing system - ✅ No file permissions or directory creation issues - ✅ Standard practice for containerized applications This fixes the deployment failure identified in the Dokploy logs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
07dd7b0e47
commit
2c277d13f6
16
DOKPLOY.md
16
DOKPLOY.md
@ -33,7 +33,16 @@ TTL: 3600
|
||||
|
||||
1. **Inside your project**, click **"Create Service"**
|
||||
2. **Select Service Type**: **"Compose"**
|
||||
3. **Choose Compose Type**: **"Docker Compose"** (not Stack)
|
||||
3. **Fill the "Create Compose" form**:
|
||||
|
||||
### 📝 Form Fields to Fill:
|
||||
|
||||
- **Name**: `Django Template` *(or your preferred service name)*
|
||||
- **App Name**: `django-template-prod` *(unique identifier for this service)*
|
||||
- **Compose Type**: `Docker Compose` *(keep as selected)*
|
||||
- **Description**: `Modern Django template with Tailwind CSS, authentication, and PostgreSQL database`
|
||||
|
||||
4. **Click "Create"** to proceed to configuration
|
||||
|
||||
## 📂 Step 4: Configure Repository Source
|
||||
|
||||
@ -236,6 +245,11 @@ python manage.py collectstatic --noinput
|
||||
# - Network connectivity issues
|
||||
```
|
||||
|
||||
### **Django Logging Error (FileNotFoundError)**
|
||||
If you see error: `FileNotFoundError: [Errno 2] No such file or directory: '/var/log/django/django.log'`
|
||||
|
||||
**Solution**: This is already fixed in the latest version. The production settings now use console logging only, which is Docker-friendly and works with Dokploy's log viewing system.
|
||||
|
||||
### **Domain Not Accessible**
|
||||
```bash
|
||||
# Check DNS propagation
|
||||
|
||||
@ -30,14 +30,12 @@ LOGGING = {
|
||||
'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
'simple': {
|
||||
'format': '{levelname} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': '/var/log/django/django.log',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'console': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.StreamHandler',
|
||||
@ -46,12 +44,18 @@ LOGGING = {
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['console'],
|
||||
'level': 'INFO',
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['file', 'console'],
|
||||
'handlers': ['console'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'django.request': {
|
||||
'handlers': ['console'],
|
||||
'level': 'ERROR',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user