I'm attempting to gather information when our sites encounter an internal server error. We have many applications that were never set up with proper error logging and when an issue occurs our clients don't give us the best information to work with. What I would like to do is that when a 500 happens, I would like to collect data about where the issue happened such as:
- The page the user was on
- Any data associated with the page ($_GET, $_POST, etc)
I've set up custom error pages on our server (IIS 7) with the following config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="500" />
<error statusCode="500" path="/error.php?code=500" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
And on that page I'm just var_dump-ing $_POST and $_GET to see if anything in those gets through to the error page, but it doesn't. My goal on a 500 error would be:
- Gather data about the page/user at time of error
- Send email to support team about issue containing the gathered data
Is there any way to collect that data and have the custom error page see it?
error.php:
switch($ErrorCode){
case '500':
var_dump($_REQUEST, $_POST, $_GET);
echo "internal server error";
break;
}
In all cases $_POST is empty even though I submitted a form to get this error and $_GET contains this (which makes sense):
array(2) {
["code"]=>
string(3) "500"
["500;http://icom-sbs/test_php"]=>
string(0) ""
}
4/19 Update
I played with some ideas, and the main one being storing useful data in a session variable. I attempted to store some form data in a session variable on the test page that gives the error, but it never gets into the session. It seems like the server detects that an error will occur on the page so it never even executes any code on the page and immediately executes the error page.