Where are PHP errors logged to if the error_log directive simply says "error_log"?

When the value simply says error_log (or error_log = error_log in your php.ini file), that means the errors will be written to a file called error_log in the same directory that the error occurs.

So, if you have a file called index.php in /home/user/public_html/ that throws an error, the error will be written to: /home/user/public_html/error_log.

If you have file called resize.php in /home/user/public_html/admin/images/ that throws an error, then the errors will be written to: /home/user/public_html/admin/images/error_log


Source: Display and log errors for PHP


Quote from the documentation:

error_log string

Name of the file where script errors should be logged. The file should be writable by the web server's user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslog(3) and on Windows NT it means the event log. The system logger is not supported on Windows 95. See also: syslog(). If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache or stderr in CLI.

So, when the value is not set (which is the default) it will be sent to the parent error logger, which is apache (if run via it) or stderr if you run the script on the command line.

If you use the script via apache you will have to look at the apache error log, usually in /var/log/apache or /var/log/httpd, depending on your distribution. You can check the apache configuration file for the exact location.

Edit:

I just noticed I misread your question, I guess you mean error_log has the actual value error_log?

I just did some testing. When I set error_log to a value like php_errors.log PHP still writes the error messages to the apache error log. It behaves as if the value was empty. When I set the value to a full path (e.g. /tmp/php_errors.log) then it writes the errors to the specified file.

So I guess in your case it writes the errors to the apache error log file.

Of course you can set your own log file be adding

ini_set("error_log", "/tmp/php_errors.log");

to your PHP files where you need it (if it hasn't been disabled by an administrator).

Tags:

Php

Error Log