In grails, how can I add some code to the UrlMappings.groovy (ex: println) so that I can figure out what the request URI is and which mapping is getting hit (if any)?
Background:
In this situation, there are two servers which serve different things based on file extension. So, the two servers need to always see file extensions for error processing to continue. Otherwise, the servers get confused and 1 serves up a 404 page instead of our 500 page.
The bigger picture involves taking a 500 response due to something like a NullPointerException and tracing it through the code to see what is happening.
I added code like the following which is at http://jetlet.blogspot.com/2010/08/grails-exception-handling-with-response.html :
"500" (controller: "error", action: "internalError")
In testing this, I am throwing a NullPointerException (NPE) on purpose. The 500 handling is called and 500 page is served up when entering in the URL into the browser's address bar. However, when posting a form to the server and having the processing code blow up on purpose with a NPE, the "500" handling code does not get called. The URL in the form's action seems to end with an extension. So, not sure why the difference in behavior between the GET (browser URL) and POST (form submission).
Thanks for insights and thoughts on tracking this down !
In your Config.groovy you can modify your log4j settings for url mapping events by adding
all 'org.codehaus.groovy.grails.web.mapping'
to your existing log4j settings. all is the most verbose setting so it can be tuned back if that starts giving you too much. You can find more information in the official grails documentation here : http://grails.org/doc/latest/guide/3.%20Configuration.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With