14

I am unsure is that is a Nginx or PHP-FPM setting, but long log lines are getting truncated. Is there a setting to increase the max log line length?

5 Answers 5

5

The limit of 1024 characters is hard-coded in php-fpm not nginx.

If you want to go over 2048 characters you need to re-compiled both nginx and php-fpm, else only php-fpm.

There is a full solution with patches here for 8192 characters: https://forums.freebsd.org/threads/56543/

1
  • You don't need to recompile. See my answer below.
    – Max S.
    Jul 19 at 21:55
5

I recommend using php 7.3

From https://www.php.net/ChangeLog-7.php :

Fixed bug #69031 (Long messages into stdout/stderr are truncated incorrectly) - added new log related FPM configuration options: log_limit, log_buffering and decorate_workers_output.

4

You need to recompile Nginx if you want log lines longer than 2048 bytes. From http://wiki.nginx.org/HttpLuaModule:

There is a hard-coded length limitation on the error messages in the Nginx core. It is 2048 bytes at most, including the trailing newlines and the leading timestamps. You can manually modify this limit by modifying the NGX_MAX_ERROR_STR macro definition in the src/core/ngx_log.h file in the Nginx source tree. If the message size exceeds this limit, the Nginx core will truncate the message text automatically.

1
  • Recompiled with increased NGX_MAX_ERROR_STR. Did not help, same as before. May 31, 2016 at 13:01
3

I believe you need to have a look at

log_errors_max_len

From here

2
  • 1
    This is correct answer. Increase log_errors_max_len in php.ini, solve this problem.
    – James M
    May 17, 2018 at 12:20
  • 1
    This did not solve the problem for me with php7.3-fpm. The log_limit setting in php-fpm.conf is the place to go, per @realization and Max's answers.
    – John Rix
    Aug 27, 2021 at 10:03
2

Open /etc/php-fpm.conf and update the value of log_limit = 4096 or higher if you like, then systemctl restart php-fpm.

4
  • 2
    It might be worth mentioning this wouldn't work in versions prior to PHP 7.3.
    – pstryk
    Oct 28, 2021 at 8:09
  • From the comments in the conf file, this only controls the "limit on number of characters in a single line"
    – miken32
    Feb 9 at 23:20
  • @miken32 That's exactly what Jason asked.
    – Max S.
    Feb 10 at 3:37
  • Indeed it is; I was looking at a few questions at the same time about log output getting cut off and didn't notice this question was specifically about line length!
    – miken32
    Feb 10 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .