Filtering Syslog Messages

The syslog() function can be used to generate a log message that will be then processed by the operating system’s logger. A new configuration option, syslog.filter, was introduced in PHP 7.3 for optionally filtering these messages before they are passed on to the operating system’s logger:

  • syslog.filter=no-ctrl (default) passes messages after removing all control characters
  • syslog.filter=ascii passes messages after removing all characters that are not printable ASCII characters or newlines
  • syslog.filter=all passes messages unchanged but splitting them at newlines
  • syslog.filter=raw passes messages unchanged and without splitting them at newlines

Depending on how your operating system’s logger processes messages sent by PHP, appropriate filtering must be configured. Otherwise messages may become useless at best or a security risk at worst.