Re: Way to record what URL an error originated from in my localhost file?
My needs are in my Tomcat/localhost log file, I would like as much information as possible to appear accompanying exceptions that get generated in there. At the least, I would like to have the request URI precede the error in the localhost log. Even though I have defined error pages in my web.xml file, that doesn't interact with the localhost log, right? So what options are available to me to put request URIs (and other info) into the localhost log? Thanks, - Dave Christopher Schultz-2 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave, On 5/21/2010 4:41 PM, laredotornado wrote: Thanks for this suggestion. Just to be sure I'm understanding correctly, the procedure would be 1. Add an error-page element to my xml doc that will be visited whenever an exception is generated from my JSP or servlet. 2. Configure valve to output a stack trace and the original request URI that generated the error. Is that right? I would choose one or the other: AccessLogValve /might/ be able to meet your needs, depending on what they are. If not, implement your own error page that logs whatever information you want to wherever you want it to go. Also is valve smart enough to understand that I don't want to see 500.jsp in my log file but rather something like search_results.jsp?category=1 ? I think the AccessLogValve only logs original requests -- that is, it won't log included or forwarded files like error pages. I must admit, though, that I don't really use the AccessLogValve -- I have Apache httpd doing my logging for me. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkv3zjAACgkQ9CaO5/Lv0PAotACgwgcboVKDnFhtN6N/QRCxOKFR yAcAoJFQ+ARwsJ43xGbJfvS3xVlnF5sw =BNo0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- View this message in context: http://old.nabble.com/Way-to-record-what-URL-an-error-originated-from-in-my-localhost-file--tp28626297p28659165.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Way to record what URL an error originated from in my localhost file?
From: laredotornado [mailto:laredotorn...@gmail.com] Subject: Re: Way to record what URL an error originated from in my localhost file? Even though I have defined error pages in my web.xml file, that doesn't interact with the localhost log, right? Correct; you have to write code in the servlets that handle the error pages to make log entries. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Way to record what URL an error originated from in my localhost file?
2010/5/22 laredotornado laredotorn...@gmail.com: Thanks for this suggestion. Just to be sure I'm understanding correctly, the procedure would be In general your understanding is correct, but _read_ the servlet spec, chapter SRV.9.9 Error Handling, as you were told already. That there is a valve somewhere is just implementation details. Specifications for Tomcat 6: Servlet spec: http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index2.html JSP spec: http://jcp.org/aboutJava/communityprocess/final/jsr245/index.html Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Way to record what URL an error originated from in my localhost file?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave, On 5/21/2010 4:41 PM, laredotornado wrote: Thanks for this suggestion. Just to be sure I'm understanding correctly, the procedure would be 1. Add an error-page element to my xml doc that will be visited whenever an exception is generated from my JSP or servlet. 2. Configure valve to output a stack trace and the original request URI that generated the error. Is that right? I would choose one or the other: AccessLogValve /might/ be able to meet your needs, depending on what they are. If not, implement your own error page that logs whatever information you want to wherever you want it to go. Also is valve smart enough to understand that I don't want to see 500.jsp in my log file but rather something like search_results.jsp?category=1 ? I think the AccessLogValve only logs original requests -- that is, it won't log included or forwarded files like error pages. I must admit, though, that I don't really use the AccessLogValve -- I have Apache httpd doing my logging for me. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkv3zjAACgkQ9CaO5/Lv0PAotACgwgcboVKDnFhtN6N/QRCxOKFR yAcAoJFQ+ARwsJ43xGbJfvS3xVlnF5sw =BNo0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Way to record what URL an error originated from in my localhost file?
Hi Chris, Thanks for this suggestion. Just to be sure I'm understanding correctly, the procedure would be 1. Add an error-page element to my xml doc that will be visited whenever an exception is generated from my JSP or servlet. 2. Configure valve to output a stack trace and the original request URI that generated the error. Is that right? Also is valve smart enough to understand that I don't want to see 500.jsp in my log file but rather something like search_results.jsp?category=1 ? Thanks again, - Dave Christopher Schultz-2 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave, On 5/20/2010 5:30 PM, laredotornado wrote: Is there a way to configure Tomcat to record what the URL was in the browser when this error occurred? Do you have any error-page elements in your web.xml? Do you have custom error pages? If you do, the best place to put this kind of stuff is in your custom error pages - if they are either JSPs or some other dynamic resource. See section 9.9 of the servlet spec, and you'll find that you can obtain the original URL and other interesting information using request attributes: javax.servlet.error.status_code javax.servlet.error.exception_type javax.servlet.error.message javax.servlet.error.exception javax.servlet.error.request_uri javax.servlet.error.servlet_name While I'm at it, is there a way to also link in all session and request data at the time of the error (since the request may have been submitted via HTTP POST)? The best thing for you to do is manually dump that information when an error occurs. I suppose there's the possibility that you could set up an AccessLogValve that only logs when an error occurs: Valve className=org.apache.catalina.valves.AccessLogValve ... [file and path parameters] ... condition=javax.servlet.error.request_uri pattern=[%t] %a %{javax.servlet.error.request_uri}r (no CRLF) %{my.session.attribute}s (no CRLF here, either) %{my.other.session.attribute}s / See the documentation for AccessLogValve to see what all those setting mean. This can't dump the /entire/ session, but it can dump pre-defined session attributes. It also can't dump the non-GET request parameters. If you want to look at ExtendedAccessLogValve, it can do some more exciting things, though I think you have to know the parameter names beforehand: it can't simply dump the entire set of request parameters. Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkv1uOoACgkQ9CaO5/Lv0PD3UQCfS3J7W0kcs+UVKkl4+5nqIfCS RcEAn0G+pD9BgeOIkITbZmz/0fJk9n4D =shmH -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- View this message in context: http://old.nabble.com/Way-to-record-what-URL-an-error-originated-from-in-my-localhost-file--tp28626297p28638705.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Way to record what URL an error originated from in my localhost file?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave, On 5/20/2010 5:30 PM, laredotornado wrote: Is there a way to configure Tomcat to record what the URL was in the browser when this error occurred? Do you have any error-page elements in your web.xml? Do you have custom error pages? If you do, the best place to put this kind of stuff is in your custom error pages - if they are either JSPs or some other dynamic resource. See section 9.9 of the servlet spec, and you'll find that you can obtain the original URL and other interesting information using request attributes: javax.servlet.error.status_code javax.servlet.error.exception_type javax.servlet.error.message javax.servlet.error.exception javax.servlet.error.request_uri javax.servlet.error.servlet_name While I'm at it, is there a way to also link in all session and request data at the time of the error (since the request may have been submitted via HTTP POST)? The best thing for you to do is manually dump that information when an error occurs. I suppose there's the possibility that you could set up an AccessLogValve that only logs when an error occurs: Valve className=org.apache.catalina.valves.AccessLogValve ... [file and path parameters] ... condition=javax.servlet.error.request_uri pattern=[%t] %a %{javax.servlet.error.request_uri}r (no CRLF) %{my.session.attribute}s (no CRLF here, either) %{my.other.session.attribute}s / See the documentation for AccessLogValve to see what all those setting mean. This can't dump the /entire/ session, but it can dump pre-defined session attributes. It also can't dump the non-GET request parameters. If you want to look at ExtendedAccessLogValve, it can do some more exciting things, though I think you have to know the parameter names beforehand: it can't simply dump the entire set of request parameters. Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkv1uOoACgkQ9CaO5/Lv0PD3UQCfS3J7W0kcs+UVKkl4+5nqIfCS RcEAn0G+pD9BgeOIkITbZmz/0fJk9n4D =shmH -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Way to record what URL an error originated from in my localhost file?
-Original Message- From: Christopher Schultz [mailto:ch...@christopherschultz.net] Sent: Thursday, May 20, 2010 3:34 PM To: Tomcat Users List Subject: Re: Way to record what URL an error originated from in my localhost file? Valve className=org.apache.catalina.valves.AccessLogValve ... [file and path parameters] ... condition=javax.servlet.error.request_uri pattern=[%t] %a %{javax.servlet.error.request_uri}r (no CRLF) %{my.session.attribute}s (no CRLF here, either) %{my.other.session.attribute}s / If you want to look at ExtendedAccessLogValve, it can do some more exciting things, though I think you have to know the parameter names beforehand: it can't simply dump the entire set of request parameters. Hope that helps, - -chris Very nice example, thanks Chris. Where is ExtendedAccessLogValve? http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html
RE: Way to record what URL an error originated from in my localhost file?
-Original Message- From: Leo Donahue - PLANDEVX [mailto:leodona...@mail.maricopa.gov] Sent: Thursday, May 20, 2010 3:57 PM To: 'Tomcat Users List' Subject: RE: Way to record what URL an error originated from in my localhost file? Very nice example, thanks Chris. Where is ExtendedAccessLogValve? http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html Found it. Haven't looked in here before, sorry. http://tomcat.apache.org/tomcat-6.0-doc/api/index.html