如何包含GET& PHP错误日志中的POST数据 [英] How to include GET & POST data in PHP error log

查看:52
本文介绍了如何包含GET& PHP错误日志中的POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让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 FATALWARNING错误以及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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆