Skip to content

Instantly share code, notes, and snippets.

@conkonig
Last active September 2, 2021 17:30
Show Gist options
  • Save conkonig/0d6295f3973a8de86157b27ee99f8d3d to your computer and use it in GitHub Desktop.
Save conkonig/0d6295f3973a8de86157b27ee99f8d3d to your computer and use it in GitHub Desktop.
Accessing custom error/output logging from a docker container running the standard wordpress image
# Accessing the logs when you want to test the output of a variable in PHP without using something totally outlandish like a php debugger because aint nobody got time for dat..
#### terminal into wp docker container
docker exec -it your_container_id bash
#### install nano / vim so you can actually change stuff
apt-get update && apt-get install vim nano
#### modify the php.ini file at /usr/local/etc/php/conf.d/conf.ini (use phpinfo(); on any page in your app to see where your php conf.ini is)
nano /usr/local/etc/php/conf.d/conf.ini
#### add the following lines
log_errors=on
error_log=/dev/stderr
### Enjoy your logged outputs using the php code here:
<?php error_log("YOUR_KEYWORD and some nice comments to log here.. " . json_encode($your_variable); ?>
### Open a terminal which will follow logs directly related to your keyword:
docker logs -f your_container_id 2>&1>/dev/null | grep -i YOUR_KEYWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment