I have two servers, one is the public server, one is my development server.
Both have the same OS version (CentOS7.7), both use the SAME setup for php (remi), both have the SAME php.ini, both have the same packages (plus versions!) installed - except a few non apache/php related packages (development machine) they are nearly identical machines.
Both used to log all php errors and error_log() to the php.ini defined error_log file: "/var/log/php". I have just updated to php 7.3, everything is working fine EXCEPT the logging. Now the development machine logs to php log while the public machine logs to the apache error logs.
I cannot work out why this is the case and I need some help with this, please.
On BOTH machines in the php.ini file I have set:
display_errors = Off
display_startup_errors = Off
log_errors = On
html_errors = Off
error_log = /var/log/php
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
On both machines the permissions are correct:
[user@PUBLIC /var/log/httpd] #>ls -la /var/log/php
-rw-rw----. 1 apachedaemon apachedaemon 199923 Nov 19 10:11 /var/log/php
[user@DEVELOPMENT /var/log] #>ls -la /var/log/php
-rw-rw---- 1 apachedaemon apachedaemon 158103 Nov 19 10:58 /var/log/php
On both machines I have a php script:
<?php
ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
error_log("---------------------------------- start error test");
error_log($NotDefined);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>php error test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>php error test</h1>
<p> </p>
</body>
</html>
<?php
error_log("end");
?>
On the public machine I see this:
==> 1.2.3.4_ssl_error_log <==
[Tue Nov 19 10:43:07.257073 2019] [php7:notice] [pid 4462] [client W.X.Y.Z:44844] ---------------------------------- start error test
[Tue Nov 19 10:43:07.257126 2019] [php7:notice] [pid 4462] [client W.X.Y.Z:44844] PHP Notice: Undefined variable: NotDefined in /PATH/errorTest.php on line 8
[Tue Nov 19 10:43:07.257137 2019] [php7:notice] [pid 4462] [client W.X.Y.Z:44844]
[Tue Nov 19 10:43:07.257147 2019] [php7:notice] [pid 4462] [client W.X.Y.Z:44844] end
On the development machine I see this (this is the correct way):
==> /var/log/php <==
[19-Nov-2019 10:30:28 Australia/Melbourne] ---------------------------------- start error test
[19-Nov-2019 10:30:28 Australia/Melbourne] PHP Notice: Undefined variable: NotDefined in /PATH/errorTest.php on line 8
[19-Nov-2019 10:30:28 Australia/Melbourne]
[19-Nov-2019 10:30:28 Australia/Melbourne] end
What am I doing wrong? Why does one server log to php error log while the other server logs to the apache error logs?
This IS annoying, as ALL php error log messages are all over the place and not in ONE log file as it USED to be before upgrading to php7.3
Please help, thanks.
$NotDefined
? – Alberto Sinigagliaerror_log = /var/log/php-scripts.log
that says to theerror_log
function where to put the logs – Alberto Sinigaglia