Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Nginx error_log getting truncated

Tags:

php

logging

nginx

I'm running nginx and PHP 5.5 and all my error_log messages are getting truncated when the string that's passed is long.

I've updated my php.ini file and increased the log max length from 1024 to 0 (no maximum) and it's still happening.

like image 639
vutran Avatar asked Jan 13 '23 06:01

vutran


2 Answers

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.

like image 123
Domecraft Avatar answered Jan 20 '23 12:01

Domecraft


The 1024 character limit is hard-coded in php-fpm and you will need to re-compile it.

If you want to go over 2048 characters you will need to re-compile nginx too.

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

like image 39
Daniel Ylitalo Avatar answered Jan 20 '23 13:01

Daniel Ylitalo