FWIW, my filter logs entry/exit stamps along with some extra
info for debugging (thread-id is useful to correlate against
Tomcat thread dumps), roughly:
  timestamp
  thread-id (e.g. "http80-Processor22")
  request_id
  user (my application-specific logged-in user)
  stamp_type ("processing" or "processed")
  other info as appropriate

e.g.:
  2008-06-04 12:24:19,940 http80-Processor22 19665 userA processing
'/jsp/portal/subscriber.jsp'
  2008-06-04 12:24:21,034 http80-Processor22 19665 userA processed in 1094
msec
  2008-06-04 12:24:28,178 http80-Processor84 19667 userB processing
'/jsp/portal/tx_detail.jsp'

Processing is basically an awk (gawk) script along the lines of:
  / processing / {
    a[$3 " " $4 " " $5] = $7
    t[$3 " " $4 " " $5] = $1 " " $2
  }

  / processed / {
    delete a[$3 " " $4 " " $5]
    delete t[$3 " " $4 " " $5]
  }

  END {
    now = systime()
    for(u in a) {
      runtime = now - to_unixtime(t[u])
      print u "  " format_dur(runtime) "  " t[u] "  " a[u]
    }
  }

Leading to output like:
  http80-Processor23 21428 userC  6s  2008-06-04 12:35:00,899
'/jsp/top/jsp/orders.jsp'
  http80-Processor32 21433 userB  2s  2008-06-04 12:35:04,282
'/jsp/portal/transactions.jsp'
  http80-Processor10 21437 userD  0s  2008-06-04 12:35:06,151
'/jsp/portal/sub_tx.jsp'


On Wed, Jun 4, 2008 at 7:51 AM, Álvaro Morillas (Sortes Ing. Inf. S. L. ) <
[EMAIL PROTECTED]> wrote:

> Thank you, Jim and David. I've been trying setting a Filter and it works
> ok.
> Now I must figure out how to research the logs to find requests not served,
> but I'm afraid it's a topic out of this mailing list.
>
>
>
> Álvaro Morillas Correa
> VicioJuegos.com - Sortes Ing. Inf., S.L.
>
> Plaza Mayor, 25, 1º, Of. 9-B
> 28911 Leganés (Madrid)
> Teléfono: 916943388 – Móvil: 617315926
> Horario: L-J: 9:00-14:00, 15:00-18:30 | V: 9:00-15:00
>
>
> -----Mensaje original-----
> De: David Fisher [mailto:[EMAIL PROTECTED]
> Enviado el: martes, 03 de junio de 2008 17:39
> Para: Tomcat Users List
> Asunto: Re: Requests being processed at a certain moment
>
> Alvaro,
>
> You certainly can easily use a Filter with your JSPs.
>
> Take a look at the jsp-examples webapps included with tomcat. If you
> look at WEB-INF/web.xml and the structure of WEB-INF/classes/ you
> should see how to use the example that Jim provided.
>
> For example RequestDumper:
>
> In web.xml
>
>     <filter-mapping>
>         <filter-name>Request Dumper Filter</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
> In classes/filters/RequestDumper.java:
>
>     public void doFilter(ServletRequest request, ServletResponse
> response,
>                          FilterChain chain)
>         throws IOException, ServletException {
>
>         if (filterConfig == null)
>             return;
>
>         // Render the generic servlet request properties
>         StringWriter sw = new StringWriter();
>         PrintWriter writer = new PrintWriter(sw);
>         writer.println("Request Received at " +
>                        (new Timestamp(System.currentTimeMillis())));
>        ....
>         // Log the resulting string
>         writer.flush();
>
> filterConfig.getServletContext().log(sw.getBuffer().toString());
>
>         // Pass control on to the next filter
>         chain.doFilter(request, response);
>
>     }
>
> I'm sure you can combine these examples.
>
> Good luck. Don't be afraid of Servlets they are your friend. You'll
> certainly want to know them if you need to do any binary content.
>
> Regards,
> Dave
>
> On Jun 3, 2008, at 10:15 AM, Álvaro Morillas (Sortes Ing. Inf. S.L.)
> wrote:
>
> > Although I don't use servlets, only jsp's, it's a solution I've
> > thought,
> > using a log taglib. The problem is that I must insert the code in
> > every jsp
> > and it's painful XD
> >
> > I was looking for an easier solution if it's available.
> >
> > Thanks anyway :)
> >
> >
> >
> > Álvaro Morillas Correa
> > VicioJuegos.com - Sortes Ing. Inf., S.L.
> >
> > Plaza Mayor, 25, 1º, Of. 9-B
> > 28911 Leganés (Madrid)
> > Teléfono: 916943388 – Móvil: 617315926
> > Horario: L-J: 9:00-14:00, 15:00-18:30 | V: 9:00-15:00
> >
> >
> > -----Mensaje original-----
> > De: Jim Cox [mailto:[EMAIL PROTECTED]
> > Enviado el: martes, 03 de junio de 2008 16:30
> > Para: Tomcat Users List
> > Asunto: Re: Requests being processed at a certain moment
> >
> > I use a filter servlet to log entry/exit timestamps for requests
> > along with
> > some shell scripting to process the logs looking for "still open"
> > requests.
> > I've been using it for over a year for a production site, it's been
> > very
> > useful for debugging unexplained slowdowns, hangs, etc.
> >
> > Filter is pretty simple, essentially:
> >
> > public void doFilter(...) {
> >  int request_id = ++s_request_id ;
> >  long lStart = System.currentTimeMillis() ;
> >  logger_.info(request_id + " processing request for '" +
> > sRequestedUrl +
> > "'") ;
> >  try {
> >    fc.doFilter(request, response) ;
> >  }
> >  finally {
> >    logger_.info(request_id + " processed in " +
> > (System.currentTimeMillis()
> > - lStart) + " msec") ;
> >  }
> > }
> >
> >
> > On Tue, Jun 3, 2008 at 10:15 AM, Álvaro Morillas (Sortes Ing. Inf.
> > S. L. ) <
> > [EMAIL PROTECTED]> wrote:
> >
> >> Hi everyone. This is my first post in this group. I hope this
> >> question
> >> hasn't been answered before.
> >>
> >>
> >>
> >> I have a problem with my web application. It is growing and in
> >> certain
> > peak
> >> moments the server gets very busy. I work with Tomcat 5.5 and IIS.
> >> I think
> >> the problem is within my programming (not configuration). Because
> >> of that
> >> I'm trying to see what requests are being processed in a certain
> >> moment by
> >> Tomcat and for how long they've been there so I can tune them.
> >>
> >>
> >>
> >> Is there any application I can use to see that? Or I have to use
> >> the logs
> >> and analize them in any way?
> >>
> >>
> >>
> >> I hope there is an easy solution for my problem.
> >>
> >>
> >>
> >> Thanks in advance.
> >>
> >>
> >>
> >> --------------------------------------------------------
> >>
> >> Álvaro Morillas Correa
> >>
> >> Sortes Ingeniería Informática, S.L.
> >>
> >> http://www.sortes.com
> >>
> >> Pza. Mayor, 25, Of. 9-B - 28911 Leganés (Madrid)
> >>
> >> Horario: L-J: 9:00-14:00 15:00-18:30 V: 9:00-15:00
> >>
> >> Tfno: 91 694 33 88 Fax: 91 693 10 47
> >>
> >> --------------------------------------------------------
> >>
> >>
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to