[Lift] Re: SQL dumping in log?
Looks good to me ... and they have Apache license ;) Br's, Marius On Jul 23, 11:33 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: Well, I'm looking at the code in DB and what we may have to do is write wrappers for Statement and PreparedStatement that would allow us to do the logging. The functions in DB mostly take user-provided functions like PreparedStatement = T, so there's no way to get at the parameters that are being provided directly. Let me noodle on this and see what I can do. We already have a SuperConnection, so I don't see a problem with a LoggingStatement and LoggingPreparedStatement. This seems common enough that there may already be a library of wrappers that we could use out there. Derek On Thu, Jul 23, 2009 at 1:23 PM, marius d. marius.dan...@gmail.com wrote: Looking a the code looks to me that the query is just a toString call for a Statement reference which won't yield what we'd expect. Just spoke with Derek about this. He'll take a look on it and eventually add this support soon enough. Br's, Marius On Jul 23, 10:01 pm, Jon jon.klei...@usit.uio.no wrote: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
You might want to look at how p6spy do things. From memory they supply a proxy jdbc driver that delegates to the actual driver to do the work. -- Ewan On Jul 23, 9:33 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: Well, I'm looking at the code in DB and what we may have to do is write wrappers for Statement and PreparedStatement that would allow us to do the logging. The functions in DB mostly take user-provided functions like PreparedStatement = T, so there's no way to get at the parameters that are being provided directly. Let me noodle on this and see what I can do. We already have a SuperConnection, so I don't see a problem with a LoggingStatement and LoggingPreparedStatement. This seems common enough that there may already be a library of wrappers that we could use out there. Derek On Thu, Jul 23, 2009 at 1:23 PM, marius d. marius.dan...@gmail.com wrote: Looking a the code looks to me that the query is just a toString call for a Statement reference which won't yield what we'd expect. Just spoke with Derek about this. He'll take a look on it and eventually add this support soon enough. Br's, Marius On Jul 23, 10:01 pm, Jon jon.klei...@usit.uio.no wrote: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Logging works ok with MySQL but not Derby as I discovered when moving to MySQL when playing with stax. -- Ewan On Jul 23, 11:27 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: Jon jon.klei...@usit.uio.no writes: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) Strange...On 1.1-SNAPSHOT I use essentially the same and get this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) INFO - Query(46): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = demou...@xx.yy INFO - Query(66): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = ? /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
With Lift 1.0 and my tiny test app. against Oracle, and this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) ... I get this: INFO - Query(73): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Query(241): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Service request (GET) /showPersons took 1418 Milliseconds /Jon On Jul 24, 12:27 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: ... Strange...On 1.1-SNAPSHOT I use essentially the same and get this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) INFO - Query(46): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = demou...@xx.yy INFO - Query(66): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = ? /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Jon jon.klei...@usit.uio.no writes: With Lift 1.0 and my tiny test app. against Oracle, and this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) ... I get this: INFO - Query(73): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Query(241): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Service request (GET) /showPersons took 1418 Milliseconds /Jon Don't know if this is a difference between Lift 1.0 and 1.1 or between JDBC drivers. My guess is it's the latter. I'm using Postgres /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
It's JDBC drivers. Essentially, we're calling toString on the PreparedStatement object. Different vendors do different things, since there's nothing in the spec about toString behavior. The advantage to using something like log4jdbc (or p6spy, haven't looked at that one) is that they will log the exact data that's being sent and received from the DB with zero changes to your code. Derek On Fri, Jul 24, 2009 at 5:46 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: Jon jon.klei...@usit.uio.no writes: With Lift 1.0 and my tiny test app. against Oracle, and this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) ... I get this: INFO - Query(73): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Query(241): oracle.jdbc.driver.t4cpreparedstatem...@10b868 INFO - Service request (GET) /showPersons took 1418 Milliseconds /Jon Don't know if this is a difference between Lift 1.0 and 1.1 or between JDBC drivers. My guess is it's the latter. I'm using Postgres /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Jon jon.klei...@usit.uio.no writes: Hi, Is it possible to dump/log all SQL statements going to the database, so that one can see all the SELECTs, INSERTs etc.? Look into DB.addLogFunc /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
I'm not sure if that logs the statements with the actual values. Does it ? Br's, Marius On Jul 23, 7:48 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: Jon jon.klei...@usit.uio.no writes: Hi, Is it possible to dump/log all SQL statements going to the database, so that one can see all the SELECTs, INSERTs etc.? Look into DB.addLogFunc /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Looking a the code looks to me that the query is just a toString call for a Statement reference which won't yield what we'd expect. Just spoke with Derek about this. He'll take a look on it and eventually add this support soon enough. Br's, Marius On Jul 23, 10:01 pm, Jon jon.klei...@usit.uio.no wrote: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Well, I'm looking at the code in DB and what we may have to do is write wrappers for Statement and PreparedStatement that would allow us to do the logging. The functions in DB mostly take user-provided functions like PreparedStatement ⇒ T, so there's no way to get at the parameters that are being provided directly. Let me noodle on this and see what I can do. We already have a SuperConnection, so I don't see a problem with a LoggingStatement and LoggingPreparedStatement. This seems common enough that there may already be a library of wrappers that we could use out there. Derek On Thu, Jul 23, 2009 at 1:23 PM, marius d. marius.dan...@gmail.com wrote: Looking a the code looks to me that the query is just a toString call for a Statement reference which won't yield what we'd expect. Just spoke with Derek about this. He'll take a look on it and eventually add this support soon enough. Br's, Marius On Jul 23, 10:01 pm, Jon jon.klei...@usit.uio.no wrote: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Well, that was quick. After a few minutes of searching, I found this: http://code.google.com/p/log4jdbc/ This seems like a much cleaner way to do the logging than to hook it into Lift directly. Thoughts? Derek On Thu, Jul 23, 2009 at 2:33 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: Well, I'm looking at the code in DB and what we may have to do is write wrappers for Statement and PreparedStatement that would allow us to do the logging. The functions in DB mostly take user-provided functions like PreparedStatement ⇒ T, so there's no way to get at the parameters that are being provided directly. Let me noodle on this and see what I can do. We already have a SuperConnection, so I don't see a problem with a LoggingStatement and LoggingPreparedStatement. This seems common enough that there may already be a library of wrappers that we could use out there. Derek On Thu, Jul 23, 2009 at 1:23 PM, marius d. marius.dan...@gmail.comwrote: Looking a the code looks to me that the query is just a toString call for a Statement reference which won't yield what we'd expect. Just spoke with Derek about this. He'll take a look on it and eventually add this support soon enough. Br's, Marius On Jul 23, 10:01 pm, Jon jon.klei...@usit.uio.no wrote: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) /Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SQL dumping in log?
Jon jon.klei...@usit.uio.no writes: On Jul 23, 8:56 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: marius d. marius.dan...@gmail.com writes: I'm not sure if that logs the statements with the actual values. Does it ? Strange, just tried it because I definitely remember seeing values being logged, but turns out not all statements have values logged and it seem just queries are logged. /Jeppe I tried this: DB.addLogFunc((query, len) = Log.info(The query: +query+ took +len + milliseconds)) ... and only got things like this: INFO - The query: b8450018-0122-a854-9ce5-00cde658 took 47 milliseconds Not exactly what I was interested in. ;-) Strange...On 1.1-SNAPSHOT I use essentially the same and get this: DB.addLogFunc ((q, t) = Log.info(Query(+t+): +q)) INFO - Query(46): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = demou...@xx.yy INFO - Query(66): SELECT users.id, users.firstname, users.lastname, users.email, users.locale, users.timezone, users.password_pw, users.password_slt, users.account_id, users.uniqueid, users.superuser, users.validated FROM users WHERE email = ? /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---