Configure php-fpm www-error.log

When I view the CentOS7 httpd/ssl_error_log it lists entries as
[Fri Nov 19 09:17:05.082214 2021] [:error] [pid 41431] [client]

In Rocky, with php-fpm, it doesn’t use the ssl_error_log, but instead it uses the /php-fpm/www-error.log and lists entries as
[19-Nov-2021 08:59:22 America/Los_Angeles]

I prefer the ssl_error_log format that includes a full timestamp and the client ip address. I don’t need to see the timezone in the logs. Is there a way to configure the www-error.log?

After several days of searching, there seems to be little to no information on how to configure logs for php-fpm. All that is set is a detail limited www-error.log with no means to customize to get entries with a client IP address and a full timestamp. Does anyone know where the php-fpm equivalents to “ssl_access_logs” an “ssl_request_logs” are located (if they exists) like those found in /var/log/httpd for php?

First, you have to understand that httpd and php-fpm are not the same thing. In older versions, httpd would use mod_php and the logging was shared, but php-fpm is separate and has it’s own logging, so there’s no rule that says it should follow the format of httpd. It does not care about things like IP address or request URI.
/var/log/php-fpm error.log www-error.log
It does have date/time, and shows the error specific to php. If you wanted to match it to a specific request, you’d check the httpd access log first, and then match the date/time with php-fpm.

@gerry666uk thanks for the reply and clarification. So there is no configuration possible to have the www-error.log include more details in an entry like IPs and URIs?

There MIGHT be some way to configure logging of php-fpm, but I’m not aware of it. Either way, I’d say the info being logged is reasonable when you bear in mind that php-fpm is not a web server.

Even when using the old mod_php, the access_log and error_log had different fields, and cross reference was needed.

I found some additional info today.

The php-fpm config is split into ‘global’ and ‘pool’, and the pool config allows some intersting logging, for example how long a script took to run, and how much memory it used. It’s even got a “slow log” option, a bit like MariaDB.

In addition to that, it’s also got an “access_log” feature, with many formatting options including date/time, but note where it says “access_log” as opposed to “error_log”.

php-fpm.conf on my system is rather bare, but it includes /etc/php-fpm.d/*.conf which looks rather cryptic.

for the access log, I not sure, based on below, where it’s located. I cannot see what $pool is defined as, or if one needs to uncomment the access.log line below for it to be active.

; The access log file
; Default: not set
;access.log = log/$pool.access.log

Are you sure you’re running the official Rocky 8.5 version of php-fpm?
Can you show the exact commands that you used to install it, e.g. enable stream, dnf install etc.

When I started this (in November), I installed Rocky8.4 as that was the latest back then. Through updates I’m at Rocky8.5. I installed PHP as follows:

dnf module reset php
dnf module enable php:7.2
dnf module install php:7.2
dnf install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring php-zip php-pear php-odbc php-pgsql php-ldap
systemctl enable --now php-fpm
systemctl restart httpd

OK, explains why I was seeing some differences. Back in 8.4, you could have installed php:7.4, but you are using 7.2. I don’t know if it will help with php-fpm logging, but you might want to try switching stream to 7.4…

To switch from 7.2 to 7.4 must I uninstall all the below and reinstall everything, or is there a method to upgrade?

 rpm -qa | grep php

Switching streams in RHEL: Chapter 6. Managing versions of Application Stream content Red Hat Enterprise Linux 8 | Red Hat Customer Portal