Logs¶
The containers log with driver: "none" (see docker-compose.yml), so docker compose logs shows nothing. nginx, PHP and WordPress write to files instead. These are mounted into system/logs/ in the project folder on the server:
| File | What is in it |
|---|---|
nginx-access.log | Every request, with status code and timings (see below) |
nginx-error.log | nginx errors, e.g. PHP-FPM not answering or connections reset |
php-slow.log | PHP stack traces for requests that took more than 5 seconds |
bedrock-debug.log | WordPress debug log |
cronlogs.log | Output from system/cronjobs |
Finding slow or failed requests¶
Each access log line ends with rt= (total seconds nginx spent on the request) and urt= (seconds spent waiting for PHP-FPM), plus host=.
cd system/logs
# GraphQL requests that took more than 5 seconds
grep '/wp/graphql' nginx-access.log | awk -F'rt=' '{split($2,a," "); if (a[1]+0 > 5) print}' | tail -50
# Non-2xx GraphQL responses per minute
grep '/wp/graphql' nginx-access.log | awk '$9 !~ /^2/ {split($4,t,":"); print t[2]":"t[3], $9}' | sort | uniq -c
499 means the caller closed the connection before WordPress answered. For /wp/graphql that is usually the Nuxt frontend giving up after its 8 second timeout.
Applying changes to the config files¶
The config files in devops/<env>/ are mounted as single files. A git pull replaces the file, but a running container keeps reading the old one. After a deploy that changes them, recreate the containers on the server: