PHP built-in server error log location

The built-in webserver doesn't log anywhere by default, so you need to provide a php.ini for it to customise this. For example, if you created a file called php.ini with this content:

error_log = /Users/me/test.log
log_errors = on
date.timezone = UTC

Then you can start PHP's built-in webserver like this:

php -S 127.0.0.1:8080 -c php.ini

And error_log() calls will be logged to the file you've specified.


Yes, PHP has built in error log functionality.

PHP logs errors to this file automatically.

If you want to log errors, use the function error_log()

The file's location changes depending upon enviroment.

e.g.

in Ubuntu 12.04, its

var/log/php_errors.log

In XAMPP windows,

\xampp\php\logs\php_errors.log

In Mac OS,

/var/log/apache2/php_errors.log


When using PHP builtin server on macOS, you need to specify error_log in your php.ini config file (php -i | grep php.ini).

If you decide with syslog (instead of a log file) such as:

error_log = syslog

Then to dump the logs, you can use log command on macOS, e.g.

log stream --predicate 'processImagePath contains "php"'

Otherwise use some specific file path for the error log (e.g. /usr/local/var/log/php-error.log).