Search code examples
phpsyslog

What is faster in php: syslog, file append or error_log


Are there any experiences on what is faster in php (i.e. less overhead, less time):

  • syslog()
  • error_log()
  • explicit file open(), append, close()

Thanks.


Solution

  • syslog will show differences in it's performance, depending on the configuration of the syslog daemon. For example, messages might get duplicated into several log files or even sent over the net. Therefore it is not really comparable with the others.

    Using PHP's error_log() or implementing file based logging on your own shouldn't show differences in it's performance (having that you implemented it efficiently). However, I expect error_log() a bit faster since it is simple and written in C, but a custom file based implementation might be more flexible, configurable and produce better/fancier messages.

    At the end you would need to benchmark and compare those solutions having a real world use case.