简体   繁体   English

如何让 PHP 在 error_log 文件中存储请求的 URL?

[英]How to get PHP to store requested URLs in error_log file?

I'm getting a bunch of errors on Production environment that I can't reproduce locally.我在生产环境中遇到了一堆无法在本地重现的错误。 Therefore I'm looking to find out which URL the user is requesting.因此,我希望找出用户请求的 URL。 This URL is currently not being outputted to the error log, so I'm just wondering how I would go by displaying that?这个 URL 目前没有被输出到错误日志中,所以我只是想知道我将如何显示它?

you can print to log file using trigger_error ( http://php.net/trigger_error ), ie:您可以使用trigger_error ( http://php.net/trigger_error ) 打印到日志文件,即:

trigger_error($_SERVER[REQUEST_URI]);

trigger_error by default generates user level notification, so it will not break anything. trigger_error默认生成用户级别的通知,所以它不会破坏任何东西。

if REQUEST_URI is not enough, please check Get the full URL in PHP .如果REQUEST_URI不够用,请检查Get the full URL in PHP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM