Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the format of PHP-FPM error log?

Tags:

php

stderr

fpm

probably a pretty simple question but how do I change the log format for FPM logs? An Entry looks like this for im in stderr:

2017/12/12 10:59:09 [error] 17#17: *6 FastCGI sent in stderr: "PHP message: 2017-12-12 11:59:09 > WARNING > WarningId: 1234 [] 

The thing I want to remove is the [error] part because in this example I'm logging a warning via monolog.

like image 266
Materno Avatar asked Dec 12 '17 11:12

Materno


People also ask

How do I get PHP-FPM logs?

A complete debug log for PHP-FPM errors can be found in the /opt/bitnami/php/var/log directory.

Where is PHP-FPM config file?

The configuration file is /etc/php- fpm. conf.

How do I view PHP error logs?

Look for the entry Configuration File (php. Find the Error handling and logging section of the php. ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log - this tells you the location of the file errors are logged to.

How do I create a PHP error log?

Enable Error Logging in php. To log errors in PHP, open the php. ini file and uncomment/add the following lines of code. If you want to enable PHP error logging in individual files, add this code at the top of the PHP file. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);


1 Answers

Since PHP 7.3 you can use

[www]
catch_workers_output = yes
decorate_workers_output = no

in php-fpm.conf (or php-fpm.d/ or pool.d/, depends on your system) to remove some extra decoration

like image 134
VolCh Avatar answered Sep 27 '22 03:09

VolCh