1

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.

1
  • 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. Commented Nov 29, 2011 at 5:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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.
@VicentePlata I think you can still handle the 500 error series using error-page in web.xml.
@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...?
@VicentePlata Hi, can i put layouts in error page which is redirected using <error-page> tag in web.xml?
@VicentePlata I am not sure what was wrong because you have given me insufficient information

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.