Docker PHP Error Logs

infrastructure
feature

(Sherwin Gaddis) #1

Recently (today) I was trying to find the PHP error log in the docker system. There is not one. So, I set out to create an error log by logging into the docker.

sudo docker exec -it standard_openemr_1

I checked the /var/log/apach2 folder for the error log. The error log that is there is a system error long with no PHP errors listed anywhere. This was disheartening because I really depend on the PHP error log to help guide if there is a technical issue it can point out.

So, I looked for the php.ini file. I found several. I edited them all to place the php_errors.log in the /var/log/apache2 folder. It didn’t work. The log file is not being written to.

In searching the web some more, I found that the log files should not be inside the container.
So said @mikesparr

The logs should be streamed out to the OS for storage.
I don’t know docker well enough to make the changes to the system.

Can a php error log be added to the next docker and it be ported out as recommended?

@MatthewVita


(Brady Miller) #2

hi @juggernautsei ,

The /var/log/apache2/error.log does contain the php errors in the openemr dockers. Ideally, this should also go into the openemr docker log. Thus, could then see it from outside the docker by doing:
docker logs <name-of-openemr-docker>
(this appears to be the docker standard regarding logging)

@dan_openemr , this would be a good thing to set up in the openemr dockers.(speaking of dockers, there are a two more unrelated things we need to do to get them ready for future 5.0.2 release in terms of upgrading users from 5.0.1 to 5.0.2).

-brady


(Sherwin Gaddis) #3

This command is very hard on the eyes. I ran it and my vision is not what it use to be. As the information just scrolled up the screen at a pace my eyes can’t catch any more. I really need a stationary view of the log file. Since I am use to looking just PHP errors. I missed those lines in between all the other stuff. I am whining because this is just not what I am use to and I am sure in time I will get over it.


(Brady Miller) #4

hi @juggernautsei ,
You could pipeline it to a nicer viewer such as less:

docker logs <name-of-openemr-docker> | less

(Brady Miller) #5

@juggernautsei ,
Check this out for lots of cool things you can do:


(Stephen Nielson) #6

@juggernautsei So this may not work if you are running a number of dockers at once, but for a single OpenEMR instance you can also just log into the docker instance. Its what I’m doing with the unit tests right now.

Here’s a paste of what I wrote for the unit testing tips:

First get your docker instance id for openemr

docker ps

That should give you a screen like so

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                                           NAMES
9c214e0ce46c        openemr/openemr:flex    "./run_openemr.sh"       7 days ago          Up 7 minutes        0.0.0.0:3000-3001->3000-3001/tcp, 0.0.0.0:8300->80/tcp, 0.0.0.0:9300->443/tcp   openemr_openemr_1
272737bb9076        mariadb:10.2            "docker-entrypoint.s…"   9 days ago          Up 7 minutes        0.0.0.0:8320->3306/tcp                                                          openemr_mysql_1
59865889c5ba        phpmyadmin/phpmyadmin   "/run.sh supervisord…"   9 days ago          Up 7 minutes        9000/tcp, 0.0.0.0:8310->80/tcp    

Note the container id is the first line to the left of the openemr/openemr:flex Image column.
Now execute the bash command against that container id.

sudo docker exec -i -t 9c214e0ce46c /bin/bash

Now you can monitor the log in the bash script that opened by running the tail command (everything after bash-4.4#).

bash-4.4# tail -f /var/log/apache2/error.log

(Sherwin Gaddis) #7

thank you for the update. I will use this.


(Brady Miller) #8

btw,
Here’s a nifty command I found somewhere to see the php error log within the openemr docker without needing to go into the docker:

docker exec -i <name-of-openemr-docker> -c 'cat /var/log/apache2/error.log'