2015-06-19 90 views
-1

我有Apache 2.4和PHP 5.6作爲模塊。 有沒有辦法將自定義錯誤發送到當前'ErrorLog'文件? 'ErrorLog'指令取決於時間(每日日誌)。 我有非常具體的要求:Apache + mod_php如何手動記錄錯誤?

  • 我不能調用trigger_error功能(錯誤信息不應顯示,僅記錄);
  • 我不能使用display_errorsnone
  • 我不能使用@運算符

任何變種?

+0

http://php.net/manual/en/function.error-log.php – MonkeyZeus

+1

http://stackoverflow.com/questions/15530039/how-to-write-to-error-log-file-in -php – MonkeyZeus

+0

我不知道日誌文件名,它不是靜態的。更多的是在本地,測試和生產服務器上的不同文件。 – SLY

回答

0

任何語言都會讓你寫信給stderr。 stderr被重定向到基本服務器ErrorLog。試試fprintf。

+0

'$ err = error_get_last();的第二個要求。 $ msg = $ err ['message']; $ stderr = fopen('php:// stderr','w'); fprintf($ stderr,「%s」,$ msg); fclose($ stderr);'沒有工作 – SLY