Add a collection for storing logs.
When catching an error thrown in the custom scripts, put it in the database. Add a view where logs can be viewed.
In each log entry, save information on what was the requested URL. Log if the rewrite was successful or ended with an error. Create a log entry for each request, not only the ones that errored.
Remove logs older than 1h