On Centos7 With PHP 7 configured to send errors to syslog, parse errors get broadcast to wall e.g. logged in users see messages like this:

Broadcast message from systemd-journald@xxxxxxxxxx (Fri 2017-03-03 22:29:05 UTC):

httpd[3465]: PHP Parse error:  Invalid numeric literal in /web/test.php on line 20

I would like to trap these messages and prevent them going to wall. I've tried this Rsyslog config:

user.*                                                /var/log/php.log
& stop

however it did not prevent the broadcast messages. Editing /etc/systemd/journald.conf to include ForwardToWall=no prevents the broadcast message... The problem is it prevents all emergency messages being displayed which is not desirable.

How can I prevent PHP parse errors being broadcast, but allow other critical system messages to be logged to console?


Turns out that putting ForwardToWall=no & ForwardToSyslog=yes into /etc/systemd/journald.conf resolves the issue.

Emerg message from PHP get caught with this custom Rsyslog config:

user.*                                                /var/log/php.log
& stop

And other emerg messages get caught later on with:

*.emerg                                                 :omusrmsg:*

Which has sends the messages to all logged in users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.