Improved logging of WebApplicationExceptions with RESTEasy
RESTEasy logs every thrown WebApplicationException with it’s full stacktrace:
This may be helpful in case of a status 500 Internal Server Error
. In case of a client error like 404 Not Found
it just bloats your logfile and doesn’t provide helpful information. RESTEasy provides a NoLogWebApplicationException to avoid this but then you won’t find any information about these errors in your application logfile. You can easily improve this by implementing your own ExceptionMapper:
Of course you should always provide a helpful error message when throwing a WebApplicationException: