Where are PHP error logs stored?
Find the error log used by the actual PHP SAPI, distinguish PHP-FPM process logs from script errors, and check permissions and framework logging.
PHP does not have one universal error-log path. The destination depends on the active SAPI, its effective configuration, and any application logging system. Start with the configuration used by the failing request, not a path copied from another server.
Check the relevant runtime
| Runtime | Where to investigate |
|---|---|
Apache module (mod_php) |
PHP's configured error_log; otherwise the SAPI logger, often Apache's configured server or virtual-host error log |
| PHP-FPM | PHP script-error settings, including pool overrides; distinguish these from the FPM process manager's own error_log |
| Managed or cPanel hosting | The provider's PHP handler and per-site settings; /usr/local/apache/logs/error_log is an Apache log path, not a guarantee that every PHP error goes there |
| CLI | The configured PHP error log, or the SAPI default destination such as stderr |
Paths under /var/log/apache2/ or /var/log/php-fpm/ are distribution conventions, not PHP requirements. Shared hosting can impose its own locations and access rules.
Configure a destination in php.ini
log_errors = On
error_log = /var/log/php-scripts.log
The PHP process must be able to write the destination, and applicable security policy must allow it. Reload or restart the relevant Apache/PHP-FPM service after changing its loaded configuration. CLI processes load their configuration when they start.
For FPM, inspect pool-level php_admin_value[error_log] and related settings as well. The FPM daemon's global log and PHP application errors are separate concepts; worker stdout/stderr capture is another setting.
Ask the correct PHP process
A temporary diagnostic page can show the effective configuration:
<?php phpinfo(); ?>
Restrict access, inspect Loaded Configuration File and the effective error_log value, then remove the page. phpinfo() can expose environment and configuration information and should not remain publicly accessible.
For CLI PHP:
php -i | grep error_log
php --ini
These commands inspect the CLI runtime. They do not establish the configuration used by a web request, which may load a different php.ini or receive FPM pool overrides.
Check framework logs separately
Laravel, CodeIgniter, ThinkPHP, and other frameworks can route application logs independently. For example, Laravel's single-file channel commonly writes storage/logs/laravel.log, but daily-file, stderr, remote, and other channels use different destinations.
Once you have identified the real files, configure collection. With Guance DataKit, check read access for the collector and verify that newly rotated files are discovered. Trigger a controlled test error and confirm its timestamp and complete stack trace reach the intended query view.
Frequently asked questions
What does “no value” for error_log mean?
The directive is unset, so PHP uses the SAPI's error logger. Apache module logging commonly goes to Apache's error log, while CLI commonly uses stderr. For FPM, inspect the handler and pool configuration rather than assuming a web-server file.
Why is nothing logged when log_errors is enabled?
Check whether error_reporting includes the error type, whether the failing request uses the configuration you inspected, and whether the process can write to the destination. Also check framework handlers and policy denials.
Should production enable display_errors?
Normally use display_errors = Off and log_errors = On, with appropriate log access controls. Diagnostics belong in logs rather than in responses that may reveal internal details.
References
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan