wood burning stoves 2.0*
The moose likes Websphere and the fly likes How to log the actual http request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "How to log the actual http request" Watch "How to log the actual http request" New topic
Author

How to log the actual http request

GS Rollen
Greenhorn

Joined: May 14, 2003
Posts: 9
How can I log the actual http request (GET /servlet/snoop HTTP/1.0) for
each request handled by WebSphere (I need something similar to an http
access.log). Also if I have a page within a frame which has the meta "refresh" tag set to 60 seconds, will it show a long entry every minute?
Thanks
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
(1) Build a logging filter and attach it to each of the servlets in your web.xml
(2) Yes. It would then show an entry every time the URL is invoked.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Originally posted by Kyle Brown:
(1) Build a logging filter and attach it to each of the servlets in your web.xml
(2) Yes. It would then show an entry every time the URL is invoked.
Kyle

(2)(a) ...Unless you code around it in your filter somehow, such as with a request parameter i.e. log=false which you could apply in the refresh tag. Beware, though, that if the user bookmarks the refreshed page, you have a problem in that the requests from the bookmark will not get logged.


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
GS Rollen
Greenhorn

Joined: May 14, 2003
Posts: 9
Originally posted by Kyle Brown:
(1) Build a logging filter and attach it to each of the servlets in your web.xml
(2) Yes. It would then show an entry every time the URL is invoked.
Kyle

Thanks for the suggestion, but as you can see, I'm just a greenhorn. Could you give me a little more detail on how to build this logging filter. For instance is this code I write in websphere? Then how would I attach this code once I had it? Oh and our environment is WAS 4.05.
One other question would be, is it is possible to get these requests to show up in the apache(IHS) access.log instead of a new custom log.
Thanks,
GS
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Ah... You should have told me you were still in WAS 4.0 earlier -- Filters are part of the Servlet 2.3 specification, and so will only work in WAS 5.0, not 4.0.
Doing this in 4.0 would be a much more challenging problem. I'm not even sure where to start in 4.0...
Kyle
GS Rollen
Greenhorn

Joined: May 14, 2003
Posts: 9
Originally posted by GS Rollen:
How can I log the actual http request (GET /servlet/snoop HTTP/1.0) for
each request handled by WebSphere (I need something similar to an http
access.log). Also if I have a page within a frame which has the meta "refresh" tag set to 60 seconds, will it show a long entry every minute?
Thanks

Wow, I can't believe this issue has not really come up before. Our team likes to see how many times pages within a Websphere application get hit. We are thinking about just writing out to a custom log each time a page is loaded. We use System.Out.println() to log our errors etc. Would prefer a more elegant way, but we will simply try to mimic the apache logs. e.g.
220.148.122.210 - - [21/Nov/2003:14:37:32 -0500] "GET /mydir/index.html HTTP/1.1"
200 9402 "http://www.was.com/" "Mozilla/5.0 (Windows; U; Win 9x 4.9
0; en-US; rv:1.5) Gecko/20031007 Firebird/0.7"
I know we can do it, the question is might there be a better way? Also, is this way efficient enough for pages which display data every 60 seconds.
Thanks
GS
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Well, actually it has come up, which is why Filters were added to the Servlet 2.3 specification...
Now that I remember it, there were MIME-type filters available in WebSphere 4.0. You could do a search in the InfoCenter in 4.0 for "MIME Filter" and see if that helps.
Kyle
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to log the actual http request
 
Similar Threads
Help! Can't Connect to Oracle USing Tomcat 4
Tomcat localAccess timing?
tracking links in a db
time taken to process a request
Login to different web-application