截断 PHP-FPM / NGINX 日志行

Truncated PHP-FPM / NGINX log lines

我的 PHP-FPM / NGINX 日志中有很多行被截断为 2048 字节,如下所示:

2022/05/15 16:06:16 [error] 899#899: *29892 FastCGI sent in stderr: "com/wordpress/wp-includes/class-wp-query.php on line 4121PHP message: PHP Warning:  Attempt to read property "post_title" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-qu
ery.php on line 4123PHP message: PHP Warning:  Attempt to read property "post_name" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4125PHP message: PHP Warning:  Attempt to read property "ID" on null in /var/www/ultimateha
ckingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4121PHP message: PHP Warning:  Attempt to read property "post_title" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4123PHP message: PHP Warning:  Attempt 
to read property "post_name" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4125PHP message: PHP Warning:  Attempt to read property "ID" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.
php on line 4121PHP message: PHP Warning:  Attempt to read property "post_title" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4123PHP message: PHP Warning:  Attempt to read property "post_name" on null in /var/www/ultima
tehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4125PHP message: PHP Warning:  Attempt to read property "ID" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4121PHP message: PHP Warning:  Attempt to r
ead property "post_title" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-query.php on line 4123PHP message: PHP Warning:  Attempt to read property "post_name" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-includes/class-wp-qu
ery.php on line 4125PHP message: PHP Warning:  Attempt to read property "ID" on null in /var/www/ultimatehackingkeyboard.com/wordpress/wp-inclu

我看过很多类似的问题,有人建议重新编译 NGINX,但我不敢相信没有其他解决方案。

我设置了以下选项,据我所知,这些选项应该可以解决问题,但它们不能:

1024 个字符的限制是 hard-coded php-fpm 而不是 nginx。

如果你想超过 2048 个字符,你需要 re-compiled nginx 和 php-fpm,否则只 php-fpm.

这里有一个包含 8192 个字符补丁的完整解决方案:https://forums.freebsd.org/threads/56543/

您可以更改配置中的日志记录设置,这样错误就不会被打印到 STDERR 并渗透到具有自身约束的各个中间层,而是被 PHP 直接写入文件.

配置指令很简单:

error_log = /path/to/file

参考: https://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

您可以将错误日志发送到标准输出并使用其他软件记录到那里。

www.conf

php_admin_value[error_log] = /dev/stdout
catch_workers_output = yes