如何包含GET& PHP错误日志中的POST数据 [英] How to include GET & POST data in PHP error log
问题描述
有没有办法让PHP
将错误记录到文件或通过电子邮件将错误INCLUDING $_POST[]
& $_GET[]
和$_SERVER[]
数据?
Is there a way to have PHP
log errors to a file or email me errors INCLUDING $_POST[]
& $_GET[]
and $_SERVER[]
data?
现在,我收到了PHP FATAL
和WARNING
错误以及404 NOT_FOUND
错误的日志,但是如果不了解用户输入和引荐来源网址,就很难调试一些错误.
Right now I get a log of PHP FATAL
and WARNING
errors and 404 NOT_FOUND
errors but it's hard to debug some errors without knowing things like user input and the referrer.
谢谢
推荐答案
error_log(print_r($_POST, true));
error_log(print_r($_GET, true));
将其放入自定义错误处理程序中,它将为您同时记录两者("true"参数使print_r返回文本而不是输出文本).
Put that into a custom error handler and it'll log both for you (the 'true' parameter makes print_r return text instead of outputting it).
You might need to boost the max line length in the error log with log_errors_max_len
, as it defaults to 1024 chars and will truncate everything after that (it won't split >1024 char data across multiple lines).
这篇关于如何包含GET& PHP错误日志中的POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!