====== Runbook: Controllare log ====== **Durata:** ~10 minuti \\ **Ruolo:** Operatore Gateway \\ **Frequenza:** Giornaliera / In caso di problemi Analisi dei log del Gateway per diagnosi errori e monitoraggio. ---- ===== Workflow ===== flowchart TD A[Aprire log] --> B[Filtrare per ERROR] B --> C{Errori trovati?} C -->|Si| D[Analizzare errore] C -->|No| E[Filtrare per WARN] D --> F[Prendere provvedimenti] E --> G{Avvisi?} G -->|Si| H[Documentare] G -->|No| I[OK - Finito] F --> I H --> I style I fill:#e8f5e9 style D fill:#ffebee style H fill:#fff3e0 ---- ===== 1. Posizioni dei Log ===== | Piattaforma | Percorso | |-----------|------| | Windows (Console) | Output console | | Windows (Service) | ''%GATEWAY_ROOT%\logs\'' o Event Log | | Linux (systemd) | ''journalctl -u data-gateway'' | | Docker | ''docker logs gateway'' | ---- ===== 2. Visualizzare ultimi log ===== **Windows (File):** # Ultime 50 righe Get-Content -Path "%GATEWAY_ROOT%\logs\gateway.log" -Tail 50 # Live-Tail Get-Content -Path "%GATEWAY_ROOT%\logs\gateway.log" -Wait -Tail 10 **Linux (systemd):** # Ultime 100 righe journalctl -u data-gateway -n 100 --no-pager # Live-Tail journalctl -u data-gateway -f **Docker:** # Ultime 100 righe docker logs --tail 100 gateway # Live-Tail docker logs -f gateway ---- ===== 3. Filtrare errori ===== **Windows:** # Voci ERROR Select-String -Path "%GATEWAY_ROOT%\logs\*.log" -Pattern "ERROR|Exception" # Oggi Get-Content "%GATEWAY_ROOT%\logs\gateway.log" | Where-Object { $_ -match "ERROR" -and $_ -match (Get-Date -Format "yyyy-MM-dd") } **Linux:** # Voci ERROR journalctl -u data-gateway --since today | grep -E "ERROR|Exception" # Oppure in file grep -E "ERROR|Exception" /var/log/gateway/gateway.log ---- ===== 4. Pattern log comuni ===== **Richiesta riuscita:** [INFO] GET /api/v1/dsn/demo/tables 200 45ms **Errore:** [ERROR] GET /api/v1/dsn/invalid/tables 404 Database 'invalid' not found [ERROR] POST /api/v1/dsn/demo/query 500 SqlException: Invalid syntax **Avviso:** [WARN] Slow query detected: 2340ms for GET /api/v1/dsn/produzione/tables/BigTable ---- ===== 5. Modificare livello log ===== In ''appsettings.json'': { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "WvdS.WebAPI.Data.Gateway": "Debug" } } } | Livello | Utilizzo | |-------|------------| | ''Trace'' | Molto dettagliato (Sviluppo) | | ''Debug'' | Informazioni di debug | | ''Information'' | Operazioni normali (Standard) | | ''Warning'' | Problemi potenziali | | ''Error'' | Errori gestiti | | ''Critical'' | Errori gravi, crash | ---- ===== 6. Checklist ===== | # | Punto di verifica | v | |---|-----------|---| | 1 | Voci ERROR esaminate | ☐ | | 2 | Voci WARN esaminate | ☐ | | 3 | Query lente annotate | ☐ | | 4 | Errori documentati/segnalati | ☐ | | 5 | Rotazione log attiva | ☐ | ---- ===== Troubleshooting ===== | Messaggio Log | Causa | Soluzione | |-------------|---------|--------| | ''Database not found'' | DSN non configurato | Verificare appsettings.json | | ''Connection refused'' | DB non raggiungibile | Verificare firewall/rete | | ''SqlException: Login failed'' | Credenziali errate | Verificare password | | ''OutOfMemoryException'' | Query troppo grande | Impostare limite ''$top'' | | ''Timeout expired'' | DB troppo lento | Ottimizzare indici | ---- ===== Configurare rotazione log ===== **Serilog (appsettings.json):** { "Serilog": { "WriteTo": [ { "Name": "File", "Args": { "path": "logs/gateway-.log", "rollingInterval": "Day", "retainedFileCountLimit": 30 } } ] } } ---- ===== Runbook Correlati ===== * [[.:health-check|Health Check]] - Verifica disponibilita * [[.:server-starten|Avviare server]] - In caso di crash * [[..:monitoring:alerting|Alerting]] - Notifiche automatiche ---- << [[.:health-check|<- Health Check]] | [[..:start|-> Panoramica Operatore]] >> ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional// {{tag>operator runbook log troubleshooting}}