I am working on Spring 3. I am going to integrate Log4j in my Application, Can I log the HTTP error like 404, 505 etc in my log file, because that errors I am redirecting to error-page from web.xml file using tag.
-
I think you may not even need to log it. Most likely, your web server / app server already includes an error log for that kind of HTTP errors. I'd recommend you to read your server logging configuration instructions.Vicente Plata– Vicente Plata2011-11-29 05:46:19 +00:00Commented Nov 29, 2011 at 5:46
Add a comment
|
1 Answer
I don't think there is an easy way to make a very detailed logging with Spring MVC.
The easiest way is to log it in your error page view file if it is a jsp but you probably cannot do very much detailed logging without pre-handling the exception in Spring controller.
This tutorial is very useful for learning how to properly handle exception from both error-page and from your controller itself. It should give you some idea of what to do.
5 Comments
Vicente Plata
If you get a 500, though, without even making it to Spring, then it won't be logged. That's why I suggested basing on the server instead of the framework.
gigadot
@VicentePlata I think you can still handle the 500 error series using error-page in web.xml.
Pravin
@gigadot Thanks for instant replay, I followed all instructions as given in Tutorial but it shows blank page with error message, can I put Layouts for this page...?
Pravin
@VicentePlata Hi, can i put layouts in error page which is redirected using <error-page> tag in web.xml?
gigadot
@VicentePlata I am not sure what was wrong because you have given me insufficient information