php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74469 syslog.ident setting ignored when logging errors (error_log=syslog)
Submitted: 2017-04-18 16:42 UTC Modified: -
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: vedad at kajtaz dot net Assigned:
Status: Open Package: FPM related
PHP Version: 7.1.4 OS: FreeBSD 10.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-04-18 16:42 UTC] vedad at kajtaz dot net
Description:
------------
The FPM setting 'syslog.ident' is ignored when PHP errors (eg. syntax errors) are being logged to syslog (error_log = syslog).

Instead of the specified `syslog.ident`, "php-fpm" is always being sent to syslog, while the explicit syslog() calls (not preceeded by an explicit openlog()) from scripts correctly use the configured `syslog.ident`.

Occurs both on latest 7.0 and 7.1 releases.

Test script:
---------------
Set the following FPM setting:

error_log = syslog
syslog.ident = foobar

Start/reload FPM, invoke a script containing a syntax error.

Expected result:
----------------
2017-04-18T18:29:00.080031+02:00 ps foobar[XXX]: PHP Parse error:  syntax error, unexpected 'return' (T_RETURN) in ... on line ...


Actual result:
--------------
2017-04-18T18:29:00.080031+02:00 ps php-fpm[XXX]: PHP Parse error:  syntax error, unexpected 'return' (T_RETURN) in ... on line ...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-18 16:49 UTC] vedad at kajtaz dot net
I was actually wrong - the explicit syslog() call also sends the (hardcoded?) "php-fpm" ident to syslog.

Only administrative logs seem to hold the correct ident, eg:

2017-04-18T18:47:21.608127+02:00 ps foobar[2553]: [NOTICE] configuration file XXXX test is successful
2017-04-18T18:47:21.645774+02:00 ps foobar[2555]: [NOTICE] fpm is running, pid 2555
2017-04-18T18:47:21.702506+02:00 ps foobar[2555]: [NOTICE] ready to handle connections
 [2017-05-03 09:19 UTC] bartjan at pc-mania dot nl
Same issue on Centos7(.3.1611 core, 3.10.0-514.10.2.el7.x86_64) with PHP 7.0.16 (although it is from the REMI Repo). PHP settings are default except the Timezone. 

Test script (run with command /usr/bin/php test.php):
---
<?php
$ident = "%TEST%";
openlog($ident, LOG_NDELAY, LOG_LOCAL7);
syslog(LOG_INFO, 'Syslog test message!');
closelog();
---
Expected result should be:
May  3 09:28:06 server01 %TEST%[14951]: Syslog test message!

But the result however is:
May  3 09:28:06 server01 php[14951]: Syslog test message!

It does not matter how the values in de openlog() function are set, it always comes back with the ident 'php'.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 05:01:28 2024 UTC