Hi, I’ve had some trouble with getting E_DEPRECATED log messages using the offical docker images.
I can see E_DEPRECATED messages with php’s display_errors = On, but they do not appear in the logs, I’ve verified that the error reporting level is appropriate, and if I set php’s ‘error_log’ to /var/log/apache2/php_errors.log the messages are written, php syntax errors are logged to docker. Here’s an example docker file with two tests:
docker exec curl 127.0.0.1/dep_err.php
triggers a deprecated error, seen only in the web output’ I expected to see it in the docker logs as well
docker exec curl 127.0.0.1/syntax_err.php throws a php syntax error
triggers a php syntax error, seen in the logs and the web output as expected.
I originally ran into this issue using the offical wordpress apache image, but simplified it down to the following example Dockerfile
FROM php:8.1.10-apache
RUN { \
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR | E_DEPRECATED'; \
echo 'display_errors = On'; \
echo 'display_startup_errors = Off'; \
echo 'log_errors = On'; \
echo 'error_log = /dev/stderr'; \
echo 'log_errors_max_len = 1024'; \
echo 'ignore_repeated_errors = On'; \
echo 'ignore_repeated_source = Off'; \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN { \
echo '<?php '; \
echo '$array = array(1,2,1,3,2,4,3,5);'; \
echo 'usort($array, fn($a, $b) => $a > $b); // this should throw a deprecated warning'; \
echo 'print_r($array);'; \
echo 'print ini_get("error_reporting");'; \
echo '?><br><a href="https://maximivanov.github.io/php-error-reporting-calculator/">error_reporting bitmask calculator</a>'; \
} > /var/www/html/dep_err.php
RUN { \
echo '<?php '; \
echo 'print "syntax error coming up" print "right about here"'; \
} > /var/www/html/syntax_err.php