PHP erroru log to syslog to a custom file pipe来跟踪错误。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP erroru log to syslog to a custom file pipe来跟踪错误。相关的知识,希望对你有一定的参考价值。

So i wanted to spit all my error_log(); and error_reporting(E_ALL); to syslog on my MacOSX and syslog would output it on a custom file.
  1. use this line so all your errors are logged.
  2. <?php
  3. ?>
  4.  
  5. go to your php.ini and set the following:
  6. error_log = syslog
  7.  
  8. go to your apache.conf (httpd.conf) and set the following:
  9. ErrorLog syslog:local3
  10.  
  11. go to your syslog.conf and set the following at the very end of the file:
  12. local3.* /var/log/httpd-php.log
  13.  
  14. then look for a line like this:
  15. *.notice;authpriv,remoteauth,ftp,install,internal.none /var/log/system.log
  16.  
  17. and add local3.none
  18. *.notice;authpriv,remoteauth,ftp,install,internal.none /var/log/system.log
  19.  
  20. this will make sure httpd php errors won't log to your /var/log/system.log file that's reserved for your machine logs.
  21.  
  22. and you are set
  23.  
  24. when you want to log something, use error_log(); example:
  25. error_log("Error: " .$user. " is not authenticated");
  26.  
  27. and then to view your errors in real time:
  28. tail -F /var/log/httpd-php.log
  29.  
  30. you can also color this using "colorize" on OSX/FreeBSD or "ccze" on Linux.
  31.  
  32. enjoy!

以上是关于PHP erroru log to syslog to a custom file pipe来跟踪错误。的主要内容,如果未能解决你的问题,请参考以下文章

在 php-fpm 中向 syslog 发送错误

Syslog:在我的 PHP 应用程序中使用 syslog 记录错误的配置是啥

从 PHP 到 Kiwi Syslog 服务器的 Syslog 问题

Debian:Syslog - 创建自己的日志文件

php添加系统日志

linux下syslog的LOG_DEBUG参数