I am trying to get the error logs out of my php docker. I found that the error.log file was going nowhere, hence modified my dockerfile like this:
Resulting in the files below:
That part is now working: running
echo "test" > /var/log/apache2/error.log
does write test to the docker logs. Plus, file permissions are not restrictive (see https://stackoverflow.com/a/12566881/3519951).I added a crashing call,
dfgdfga.test()
, but the error doesn’t show up. Same if I create a log file instead of redirecting to docker output. It remains empty.
Answer
While I was reviewing the question I figured it out. Sharing here in case it might help.
Running php -i | grep log
I found this:
It’s a surprising default in my opinion, but more than enough to explain the absence of logs. So I created a small ini file (inspired from this article) to pipe it straight to the docker logs:
And copied it in dockerfile like this: