Skip to content

Commit 3d6a751

Browse files
committed
Improved phplogging
1 parent c4eabee commit 3d6a751

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

docker/main/bin/dnsmasq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function restore_resolvconf() {
1919

2020
## Start and configure dnsmasq
2121
function dnsmasq_start() {
22-
echo "Found Webserver IP: $1"
22+
echo "[dnsmasq] Found Webserver IP: $1"
2323

2424
restore_resolvconf
2525

docker/main/bin/logwatch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail # trace ERR through pipes
4+
set -o errtrace # trace ERR through 'time command' and other functions
5+
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
6+
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
7+
8+
tail -F --quiet $2 | sed --unbuffered -e "s/^/\[$1\] /"

docker/main/conf/supervisord.conf

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,26 @@ stdout_logfile_maxbytes=0
1919
stderr_logfile=/dev/stderr
2020
stderr_logfile_maxbytes=0
2121

22-
[program:php-log]
23-
command = tail -F --quiet /tmp/php.log
22+
[program:php-log-access]
23+
command = bash /opt/docker/logwatch.sh php:access /tmp/php.access.log
24+
autostart = true
25+
autorestart = true
26+
stdout_logfile=/dev/stdout
27+
stdout_logfile_maxbytes=0
28+
stderr_logfile=/dev/stderr
29+
stderr_logfile_maxbytes=0
30+
31+
[program:php-log-slow]
32+
command = bash /opt/docker/logwatch.sh php:slow /tmp/php.slow.log
33+
autostart = true
34+
autorestart = true
35+
stdout_logfile=/dev/stdout
36+
stdout_logfile_maxbytes=0
37+
stderr_logfile=/dev/stderr
38+
stderr_logfile_maxbytes=0
39+
40+
[program:php-log-error]
41+
command = bash /opt/docker/logwatch.sh php:error /tmp/php.error.log
2442
autostart = true
2543
autorestart = true
2644
stdout_logfile=/dev/stdout

docker/main/entrypoint.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ if [ ! -f "/opt/docker/.fpm-www.conf" ]; then
4444
cp /etc/php5/fpm/pool.d/www.conf /opt/docker/.fpm-www.conf
4545
fi
4646

47-
## init log
48-
rm -f -- /tmp/php.log
49-
touch /tmp/php.log
50-
chmod 666 /tmp/php.log
47+
## Remove old logs
48+
rm -f -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
49+
touch -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
50+
chmod 666 /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log
5151

5252
# Restore original
5353
cp /opt/docker/.fpm-www.conf /etc/php5/fpm/pool.d/www.conf
@@ -64,11 +64,11 @@ pm.max_spare_servers = 3
6464
6565
catch_workers_output = yes
6666
67-
access.log = /tmp/php.log
68-
slowlog = /tmp/php.log
67+
access.log = /tmp/php.access.log
68+
slowlog = /tmp/php.slow.log
6969
request_slowlog_timeout = 10s
7070
71-
php_admin_value[error_log] = /tmp/php.log
71+
php_admin_value[error_log] = /tmp/php.error.log
7272
php_admin_flag[log_errors] = on
7373
7474
env[TYPO3_CONTEXT] = ${TYPO3_CONTEXT}

0 commit comments

Comments
 (0)