0

Is posible use syslog facilities in php error_log directive or in other way at system/server side?

Something like...

error_log = syslog:local4
error_log = syslog(LOG_LOCAL4)

Using php fpm I can set this with syslog.facility directive in fpm conf, but what about of php cli?

Thanks

icalvete
  • 987
  • 2
  • 16
  • 50
  • http://stackoverflow.com/questions/6469405/how-to-get-php-errors-to-show-on-syslog – TheClair Mar 21 '14 at 20:44
  • TheClair, I know how send errors to syslog, I want know how if is posible choose facility (local4 for example). I edit the question to explain this. Thanks. – icalvete Mar 22 '14 at 06:31

1 Answers1

3

Php default syslog's facility is "user" (and cannot be changed)

I use directive auto_prepend_file in phi.ini (this script must be under include_path)

auto_prepend_file = log.php

and

root@sp:/etc/php5/cli# cat /usr/share/php5/log.php
<?php

openlog('php-cli', 0, LOG_LOCAL4);
icalvete
  • 987
  • 2
  • 16
  • 50
  • The facility setting from openlog() seems to persist even after closelog(), so if one does not care about the tag/ident, closelog() may be called just after openlog(). Not sure if that matters as LOG_ODELAY is default. I just noticed a report on http://php.net/manual/en/function.syslog.php about a problem with apache-syslog messages being given the same tag as php-messages in the same thread when leaving syslog open. – Torin Finnemann Nov 27 '14 at 10:13