PHP's error_log() vs syslog()

你。 提交于 2020-12-30 05:30:13

问题


I'm trying to decide what functionality to use for logging to a custom file.

Background
We have several PHP processes, both running as Apaches (mod_php) and as Deamons (CLI, forked). I would like to be able to specify a log file per process/task to write to. For both the Apache processes as the Deamons, multiple processes will be writing to the same file.

Options
PHP offers both error_log() and syslog(). Both seem to offer more or less the same functionality.

My question

  • What are the pros and cons of those functions?
  • Which one to choose? (and why?)
  • What if I drop the requirement of multiple files?

回答1:


syslog sends the message to the OS logger, while error_log has multiple options, either to the OS logger, to an email, to a file, or to the SAPI logging handler, as is stated in the documentation.

Since you say yo want to write on multiple logs, I'd recommend error_log with $message_type = 3, wich lets you add messages to the file set in the $destination parameter.



来源:https://stackoverflow.com/questions/6409729/phps-error-log-vs-syslog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!