Careful there might not be a request in the request stack. There were problems when trying to use similar code in constructing the CakeErrorController. You might want to only log the URL if Router::getRequest() succeeds.

Situations like missing plugin exceptions will happen before there is a request in the router, same for things like missing connection.