====== Runbook: Check Logs ======
**Duration:** ~10 minutes \\
**Role:** Gateway Operator \\
**Frequency:** Daily / On issues
Analysis of Gateway logs for error diagnosis and monitoring.
----
===== Workflow =====
flowchart TD
A[Open logs] --> B[Filter for ERROR]
B --> C{Errors found?}
C -->|Yes| D[Analyze error]
C -->|No| E[Filter for WARN]
D --> F[Take action]
E --> G{Warnings?}
G -->|Yes| H[Document]
G -->|No| I[OK - Done]
F --> I
H --> I
style I fill:#e8f5e9
style D fill:#ffebee
style H fill:#fff3e0
----
===== 1. Log Locations =====
| Platform | Path |
|----------|------|
| Windows (Console) | Console output |
| Windows (Service) | ''%GATEWAY_ROOT%\logs\'' or Event Log |
| Linux (systemd) | ''journalctl -u data-gateway'' |
| Docker | ''docker logs gateway'' |
----
===== 2. Show Recent Logs =====
**Windows (File):**
# Last 50 lines
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):**
# Last 100 lines
journalctl -u data-gateway -n 100 --no-pager
# Live tail
journalctl -u data-gateway -f
**Docker:**
# Last 100 lines
docker logs --tail 100 gateway
# Live tail
docker logs -f gateway
----
===== 3. Filter for Errors =====
**Windows:**
# ERROR entries
Select-String -Path "%GATEWAY_ROOT%\logs\*.log" -Pattern "ERROR|Exception"
# Today
Get-Content "%GATEWAY_ROOT%\logs\gateway.log" | Where-Object { $_ -match "ERROR" -and $_ -match (Get-Date -Format "yyyy-MM-dd") }
**Linux:**
# ERROR entries
journalctl -u data-gateway --since today | grep -E "ERROR|Exception"
# Or in file
grep -E "ERROR|Exception" /var/log/gateway/gateway.log
----
===== 4. Common Log Patterns =====
**Successful request:**
[INFO] GET /api/v1/dsn/demo/tables 200 45ms
**Error:**
[ERROR] GET /api/v1/dsn/invalid/tables 404 Database 'invalid' not found
[ERROR] POST /api/v1/dsn/demo/query 500 SqlException: Invalid syntax
**Warning:**
[WARN] Slow query detected: 2340ms for GET /api/v1/dsn/production/tables/BigTable
----
===== 5. Adjust Log Level =====
In ''appsettings.json'':
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"WvdS.WebAPI.Data.Gateway": "Debug"
}
}
}
| Level | Usage |
|-------|-------|
| ''Trace'' | Very detailed (development) |
| ''Debug'' | Debugging information |
| ''Information'' | Normal operations (default) |
| ''Warning'' | Potential problems |
| ''Error'' | Errors that were handled |
| ''Critical'' | Severe errors, crash |
----
===== 6. Checklist =====
| # | Check | Done |
|---|-------|------|
| 1 | ERROR entries reviewed | [ ] |
| 2 | WARN entries reviewed | [ ] |
| 3 | Slow queries noted | [ ] |
| 4 | Errors documented/reported | [ ] |
| 5 | Log rotation active | [ ] |
----
===== Troubleshooting =====
| Log Message | Cause | Solution |
|-------------|-------|----------|
| ''Database not found'' | DSN not configured | Check appsettings.json |
| ''Connection refused'' | DB not reachable | Check firewall/network |
| ''SqlException: Login failed'' | Wrong credentials | Check password |
| ''OutOfMemoryException'' | Query too large | Set ''$top'' limit |
| ''Timeout expired'' | DB too slow | Optimize index |
----
===== Set Up Log Rotation =====
**Serilog (appsettings.json):**
{
"Serilog": {
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "logs/gateway-.log",
"rollingInterval": "Day",
"retainedFileCountLimit": 30
}
}
]
}
}
----
===== Related Runbooks =====
* [[.:health-check|Health Check]] - Availability check
* [[.:server-starten|Start Server]] - On crash
* [[..:monitoring:alerting|Alerting]] - Automatic notification
----
<< [[.:health-check|<- Health Check]] | [[..:start|-> Operator Overview]] >>
----
//Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional//
{{tag>operator runbook logs troubleshooting}}