This would first check if the php file exists, and if not it would try to open that same php file but with "-404" appended to it, so the user would still get a 404 status code, but it would also log what file was called. I hope this helps.
P.S. Sorry for replying to this topic 2 years later, but this is one of the topics that come out when you search for this issue and I think it is usefull that there is an easy solution.