查看完整版本: 如何記錄 PHP Errors Output to error_log File


lancer 2011-12-19 14:21

如何記錄 PHP Errors Output to error_log File

<div>有時如果要將 PHP 的 Error Log 另外輸出成一個檔...可以這樣做</div><br><ul type="1"><li>Login to the web server, and edit the <b>php.ini</b> file with any editor such as vi.Note: php.ini configuration file can be found at /etc/php.ini or /usr/local/lib/php.ini.</li></ul><div><br></div><ul type="1"><li>Locate <b>display_errors</b> directive, and change its value to <b>Off</b> so that the line looks like following (if not found, add in the line) to disable error output to web pages:display_errors = Off<br></li></ul><div><br></div><ul type="1"><li>Locate <b>log_errors</b> directive, and change its value to <b>On</b> so that the line looks like following (if not found, add in the line) to enable error logging to file:log_errors = On<br></li></ul><div><br></div><ul type="1"><li>Locate <b>error_log</b> directive, and modify its value to a preferred file name to save the error log file so that the line looks like following (if not found, add in the line):error_log = error_log<br>Note: Path can be included, for example, error_log = /var/log/error_log. If no path is specified, the error log file may be stored at the same directory where PHP scripts are located.<br></li></ul><div><br></div><ul type="1"><li>Save the modified php.ini.</li></ul><div><br></div><ul type="1"><li>Restart the web server. For example, Apache web server restarting command is:&nbsp;# /etc/init.d/httpd restart</li></ul><div><br></div><div>檢查看看有沒有輸出囉~~</div><div><code>tail -f /path/to/error_log</code></div>
頁: [1]
查看完整版本: 如何記錄 PHP Errors Output to error_log File