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:

Written by

developer at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store