Server: AlmaLinux 8, PHP 8.2.2
I have many servers with variety of PHP versions, on most the code below logs correctly to the specified error log file. The server I have a problem with was just upgraded to PHP 8.2.2.
I have in my php.ini
// I have tried a variety of settings
error_reporting = E_ALL
log_errors = On
display_errors = Off
html_errors = Off
error_log = /var/log/php
I have a bit of code (just the important bits)
<?php
error_reporting(E_ALL);
ini_set('log_errors', 1);
ini_set('display_errors', 0);
ini_set('error_log','/var/log/php');
mysqli_report(MYSQLI_REPORT_OFF);
// debug message
error_log("start of script");
// removed the error handling in the code
// the connection works, I know!
$MJCONN = mysqli_connect($hostname, $username, $password);
mysqli_select_db($MJCONN, $database);
// many lines of code deleted
if(!$result = mysqli_query($MJCONN, $TheQuery)) {
error_log("It's dead Jim");
exit;
}
// many lines of code deleted
// here is my error, I mispelled the variable name
while($r = mysqli_fetch_assoc($resulr))
{
// some code here
}
?>
The debug message using error_log("start of script") is correctly shown in the file, so this is NOT a permission error.
Whatever I try, the mispelled variable name error is never displayed in the log file. I even tried to mispell a function name, same nothing is displayed in the error_log file.
If I set this:
error_reporting(E_ALL);
ini_set('log_errors', 1);
ini_set('display_errors', 1);
ini_set('error_log','/var/log/php');
It works correctly and the error is displayed on the screen, which is NOT what I want.
I want syntax – or preferably all errors – logged in the error_log.
What am I doing wrong?
2
Answers
Turns out the default config file for php-fpm has changed. It now comes with a default setting
The problem with this it absolute overrides ini_set, so the following code
has no meaning anywhere in your code.
If you comment out this code like so
the setting in php.ini takes over again, but the error formatting is in shambles, the only way to fix all of this it to
to get it well formatted back to the original location, but ini_set will still not work.
Please check which
php.ini
configure file was loaded by PHP 8.2.2,You can used command line to check the
php.ini
file used :