How do I get the Apache2 PHP 8.3 error logs to be one line per error_log() function call as it used to be in previous versions?
Environment:
- Ubuntu 22.04.4
- Apache/2.4.54 (Ubuntu) (/usr/sbin/apache2)
- PHP 8.3.3 (/usr/bin/php8.3)
- libphp8.3 (/usr/lib/apache2/modules/libphp8.3.so)
Example PHP file ( /exampleErrorLog/index.php ):
<?php
error_log(basename(__DIR__).':'.__LINE__.':Example error log 1');
error_log(basename(__DIR__).':'.__LINE__.':Example error log 2');
error_log(basename(__DIR__).':'.__LINE__.':Example error log 3');
error_log(basename(__DIR__).':'.__LINE__.':Example error log 4');
Undesired PHP error log file output:
[2024-03-16 20:15:09.935468] [error] [pid 4032655] [1.2.3.4:55982] AH01071: Got error 'PHP message: exampleErrorLog:2:Example error log 1; PHP message: exampleErrorLog:3:Example error log 2; PHP message: exampleErrorLog:4:Example error log 3; PHP message: exampleErrorLog:5:Example error log 4'
Expected/Desired PHP error log file output: (as it was in all previous OS and PHP versions that I've used)
[2024-03-16 20:15:09.935468] [error] [pid 4032655] [1.2.3.4:55982] exampleErrorLog:2:Example error log 1
[2024-03-16 20:15:10.123456] [error] [pid 4032655] [1.2.3.4:55982] exampleErrorLog:3:Example error log 2
[2024-03-16 20:15:10.234567] [error] [pid 4032655] [1.2.3.4:55982] exampleErrorLog:4:Example error log 3
[2024-03-16 20:15:10.345678] [error] [pid 4032655] [1.2.3.4:55982] exampleErrorLog:5:Example error log 4
In all previous OS/PHP versions that I've used, the PHP error log file output would match the output example in the code block labeled "Expected/Desired". It seems like with the new Apache2 module for PHP 8.3 is combining all error log outputs into a single line before writing it to the log file. This causes the file output to be extremely unreadable when there is a lot of debugging outputs.
Does anyone know how to configure the new PHP module to output every error line immediately to the log file? and also preferably without the AH01071: Got error 'PHP message ....' messaging.
Right now I'm thinking that I might just have to write custom error log handlers, but that would only help for expected errors in nicely formatted code, and not unexpected errors (like parsing errors)
Thanks!
--- Edit ---
Adding "\n" to the end of the error_log() string input did not get the desired output.
<?php
error_log(basename(__DIR__).':'.__LINE__.':Example error log 1'."\n");
error_log(basename(__DIR__).':'.__LINE__.':Example error log 2'."\n");
error_log(basename(__DIR__).':'.__LINE__.':Example error log 3'."\n");
error_log(basename(__DIR__).':'.__LINE__.':Example error log 4'."\n");
Results in:
[2024-03-19 16:35:18.203237] [error] [pid 3137394] [1.2.3.4:52151] AH01071: Got error 'PHP message: exampleErrorLog:2:Example error log 1\n; PHP message: exampleErrorLog:3:Example error log 2\n; PHP message: exampleErrorLog:4:Example error log 3\n; PHP message: exampleErrorLog:5:Example error log 4\n'