• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jdbc access log valve

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, we are attempting to implement access logging to a mysql database and are successfully logging the default patterns using the jdbcaccesslogvalve.  However, we are unable to log the 'Time taken to process the request' (%D parameter).  Has anyone had any success with this parameter using the jdbcaccesslogvalve, or any suggestion/thoughts on how to get this parameter?   Thanks
 
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a Tomcat server-specific question. I've moved it to the Tomcat forum.
 
Tim Holloway
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can tell this Valve does not log processing time duration, only timestamps the request arrival time. I may be looking at docs for the wrong version of Tomcat, however.
 
Erek Wright
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be possible to extend that valve so it includes the processing time?  As a novice, i would assume that would be a much more difficult task to accomplish?      Any other thoughts or suggestions in regards to logging process times when logging to a database server?   Thanks in advance!!!      
 
Tim Holloway
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost all of the Tomcat components can be subclassed/extended. But I don't guarantee that everything you want to know is available when the Valve is invoked. Probably not, in fact, since I think it's logging incoming requests.

When a web client makes a Tomcat request, there are several stages. First, the client connects to the server's listening port. Which it may not be able to do on the first try, since Tomcat has a limited number of resources it can use there, Once the port accepts the connection, the client sends the request. Which takes time. The request may then end up queued waiting for available resources. I think this is probably where that Valve is called. Among the necessary resources is a servlet thread to handle the request, so the request remains parked in the queue until a processing thread becomes available from the processing thread pool. At that point, the request is broken down to determine which application and servlet will do the processing and sent to that servlet. JSPs compile into servlets, so they get handled by the same mechanism. Now we've entered the application code, and commonly people log this time, since it's the beginning of the interval that they have the most control over. The application does its thing and returns - and if you're logging application processing time, you look at your figurative watch to calculate how long that took. The servlet also returns a response via the reply port that was assigned to the client whent they opened the connection, and any data that hasn't already been sent to the client is sent before the connection is closed. At which time you have yet another moment in time that might be measured.

From a practical point of view, I normally worry most about end-to-end processing time - which can only be measured in the client, since it's the amount of time the user has to sit and drool while all this is going on. Secondary to that is going to be servlet processing time, which I'd normally capture or log via a listener in the webapp itself.

Finally, note that a typical web page request can easily translate into a dozen or more http requests, since every javascript file, css stylesheet, image, and so forth is an independent request of its own - and not all may even be made to the same server. Many of those requests may run in parallel (by default, Firefox can handle 10 requests at a time). So the time it takes to assemble - and then render - a web page is the sum of quite a few variables.
 
Saloon Keeper
Posts: 6522
160
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also look into a logging jdbc driver like p6spy. I don't know if it can log the duration of a query, though.

Some DBs can do this, too. MySQL, for example, can log all queries that take longer than a configurable number of seconds.
 
Tim Holloway
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:You could also look into a logging jdbc driver like p6spy. I don't know if it can log the duration of a query, though.

Some DBs can do this, too. MySQL, for example, can log all queries that take longer than a configurable number of seconds.



I think you made the same mistake I did. This isn't about logging database requests, this is about using a Tomcat Valve to log web requests made to Tomcat to a JDBC database instead of logging them to a logfile.
 
Tim Moores
Saloon Keeper
Posts: 6522
160
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe Erek can clarify what is needed. This sounds more like finding any logging solution than using a Tomcat valve in particular:

Any other thoughts or suggestions in regards to logging process times when logging to a database server?  

 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But on the other hand this sounds like logging to a database table is already working, as far as the "to a database table" part is concerned.

Erek Wright wrote:Hello, we are attempting to implement access logging to a mysql database and are successfully logging the default patterns using the jdbcaccesslogvalve.

 
Tim Holloway
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note: "JDBCAccessLogValve" doesn't mean "Valve to log JDBC Access". Tomcat does not monitor database access because Tomcat does not understand or do database access for applications. About as close as you can get is that a database connection pool jacked into Tomcat might, but Tomcat Valves are not part of connection pooling, they're access points into the Tomcat dispatch flow.

What "JDBCAccessLogValve" means is that the Tomcat web Access Log is logged via JDBC. The problem here is that the sample table given in the docs I read doesn't have a column to hold "request processing time". And, as I said, adding one probably wouldn't help since I don't think that the processing time is know when the valve is invoked - it sees the request on the way in, not on the way out.
 
Tim Moores
Saloon Keeper
Posts: 6522
160
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(sound of swooshing sound) Tim, what you were trying to say in your previous post went right by me. Got it now :-)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic