Logging: Automatische Log-Bereinigung nach 7 Tagen implementiert

This commit is contained in:
2025-08-20 08:56:07 +02:00
parent bcc6869d13
commit fcbcb07e76
2 changed files with 50 additions and 3 deletions

View File

@@ -7,7 +7,8 @@ Das Wordle-Helper Logging-System protokolliert Seitenaufrufe und Suchanfragen oh
- **Verzeichnis:** `logs/`
- **Datei:** `logs/app.log`
- **Format:** UTF-8
- **Rotation:** Keine automatische Rotation (manuell oder über externe Tools)
- **Rotation:** Automatische Rotation nach 7 Tagen
- **Backup:** Komprimierte Backup-Dateien (30 Tage aufbewahrt)
- **Verzeichnis:** Wird automatisch erstellt, falls es nicht existiert
## Protokollierte Ereignisse
@@ -50,12 +51,22 @@ logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('app.log', encoding='utf-8'),
logging.FileHandler(logs_dir / 'app.log', encoding='utf-8'),
logging.StreamHandler()
]
)
```
## Automatische Log-Bereinigung
Das System bereinigt automatisch alte Log-Dateien:
- **Rotation:** Nach 7 Tagen wird die aktuelle Log-Datei komprimiert
- **Backup:** Komprimierte Dateien werden 30 Tage aufbewahrt
- **Format:** Backup-Dateien: `app_YYYYMMDD_HHMMSS.log.gz`
- **Trigger:** Bereinigung wird bei jedem Seitenaufruf geprüft
- **Fehlerbehandlung:** Fehler bei der Bereinigung werden geloggt
## Log-Analyse
Die Log-Datei kann mit Standard-Tools analysiert werden: