Where do PHP errors go, when display errors is off for a website?

7 posts / 0 new
Last post
#1 Tue, 03/25/2014 - 09:21
amityweb

Where do PHP errors go, when display errors is off for a website?

When we receive errors in our systems (could be Modx, Expression Engine, a bespoke app), usually display errors is off in these apps by default. So we just get blank screens, or Internal Server errors.

I thought these errors would still be logged somewhere, but they never are. No PHP errors in apache error, or the users own error log in their directory.

We always have to find out how to turn errors on in the application we are using so we can see them in the browser, which is not good.

So is there some settings somewhere to make sure PHP logs errors to a file, preferably the error log in the users home/log directory, but failing that the global apache error log.

Thanks

Tue, 03/25/2014 - 10:29
Locutus

I don't know off the bat what Virtualmin configures by default, but you should be able to specify the error log location with this php.ini directive: http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

Tue, 03/25/2014 - 13:03
andreychek

Virtualmin uses the PHP config provided by the distro by default... and distros have those setup to put PHP errors and warnings into the Apache log for that domain.

PHP should log errors and warnings by default... it's possible that those have been turned off, or it's also possible that the application is, for some reason, not throwing errors as expected.

-Eric

Tue, 03/25/2014 - 13:32
amityweb

This is my php.ini file, but no PHP errors are logged anywhere. I know PHP errors occur because in my application, if I set display_errors to 1 somewhere, they are output. No log file is set, what is the default?

display_errors = Off

log_errors = On

; Log errors to specified file. PHP's default behaviour is to leave this value

; empty.

; http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

; Example:

;error_log = php_errors.log

; Log errors to syslog (Event Log on NT, not valid in Windows 95).

;error_log = syslog

Tue, 03/25/2014 - 14:34
andreychek

Howdy,

Those values are all normal, and should result in your app logging to the Apache logs.

What is "error_reporting" set to?

-Eric

Tue, 03/25/2014 - 16:00
amityweb

Error reporting in php.ini is: error_reporting = E_ALL & ~E_DEPRECATED

But in the application from earlier (Modx) site is: error_reporting(E_ALL & ~E_NOTICE);

This wad the site that resulted in a blank page. And only when I added the following line did a PHP error output to the browser: ini_set('display_errors',1);

But this is the situation on various applications we use, and on several Virtualmin servers (hence me raising the issue here).

Tue, 07/23/2019 - 07:09
olidev

I am surprised you are asking this error without checking out the PHP docs first. This really easy. Add this to your php.ini file

error_reporting = E_ALL & ~E_NOTICE
error_reporting = E_ALL & ~E_NOTICE | E_STRICT
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ER… _ERROR
error_reporting = E_ALL & ~E_NOTICE

Add this statement to parse the error logs in this PHP.ini

display_errors = on

Source: https://www.cloudways.com/blog/php-error-logging/

Topic locked