簡體   English   中英

PHP Windows 上的錯誤日志文件格式(php.ini error_log 指令)

[英]PHP Error log file format (php.ini error_log directive) on Windows

例如:
php.ini 文件

...
; Log errors to specified file.
error_log = c:/php/php.log
...

錯誤日志文件 (c:/php/php.log) 包含以下格式的每個條目:

[12-Jun-2011 12:58:55] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 12:59:01] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:01:12] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:02:11] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:11:23] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:12:10] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n

每個錯誤行兩個回車符和一個新行。

為什么會發生? 如何將錯誤日志文件更改為默認格式:

[12-Jun-2011 12:58:55] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 12:59:01] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:01:12] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:02:11] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:11:23] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:12:10] PHP Notice:  Undefined variable: test in C:\www\phpinfo.php on line 2\r\n

PHP 版本5.3.6
阿帕奇/ 2.2.15 (Win32)
在 Windows 7 Home Basic 和 Windows XP SP3 上測試,結果相同。

php.ini 文件僅包含兩個字符串

log_errors = On
error_log = c:/server/php.log

apache phpinfo() 腳本 -> http://pastehtml.com/view/awvx1vgpp.html

PS。

服務器:nginx 1.0.4
FastCGI + PHP 版本5.3.6

一切都按預期工作。
nginx phpinfo() 腳本 -> http://pastehtml.com/view/awvwvk9p9.html

還有更多的 ini 指令來控制 output 進入錯誤日志。 這些在PHP 手冊頁上進行了解釋。

默認情況下,PHP 在不加載 ini 並且僅設置了error_log並啟用日志記錄的情況下運行,它只執行 output 單行。 你也可以在你的系統上測試它,它很好地演示了命令行接口(CLI)“服務器應用程序編程接口(API)[SAPI]”:

php -n -d error_log=./error.log -d log_errors=1 -r 'error;'

使用此命令進行隔離運行並將其與您的 output 進行比較。 如果它也有兩個行尾,那么這可能是您的 php 版本的錯誤。

如果 PHP 版本沒有問題 [不是原始發布 (OP) 中的情況],那么在您的應用程序中,一些設置看起來會被更改。 您需要找出哪個設置。 可能您可以通過注冊自己的錯誤處理程序然后轉儲 ini 設置來找到它。

最后但並非最不重要的一點是,如果這不是對行尾的誤解(請參閱我的評論),那么人們可能還想查看名為error_prepend_stringerror_append_string的有關錯誤顯示的 ini 設置(但不是錯誤日志記錄)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM