Disabling select logging seems to disable inserts as well.

40 views
Skip to first unread message

sam

unread,
Sep 23, 2009, 11:15:57 PM9/23/09
to log4jdbc
Hi,

I have tried setting -Dlog4jdbc.dump.sql.select=false and it does
indeed disable logging of selects. However, I also lose logging of
inserts. When I don't set the property to false I will see logging of
my inserts as expected.

I'm using log4jdbc4-1.2alpha2.jar

Thanks

Arthur Blake

unread,
Sep 29, 2009, 6:37:38 AM9/29/09
to log4jdbc
I've never heard of this problem before. The code that implements
this is pretty straightforward:
net.sf.log4jdbc.Slf4jSpyLogDelegator:189

/**
* Determine if the given sql should be logged or not
* based on the various DumpSqlXXXXXX flags.
*
* @param sql SQL to test.
* @return true if the SQL should be logged, false if not.
*/
private boolean shouldSqlBeLogged(String sql)
{
if (sql == null)
{
return false;
}
sql = sql.trim();

if (sql.length()<6)
{
return false;
}
sql = sql.substring(0,6).toLowerCase();
return
(DriverSpy.DumpSqlSelect && "select".equals(sql)) ||
(DriverSpy.DumpSqlInsert && "insert".equals(sql)) ||
(DriverSpy.DumpSqlUpdate && "update".equals(sql)) ||
(DriverSpy.DumpSqlDelete && "delete".equals(sql)) ||
(DriverSpy.DumpSqlCreate && "create".equals(sql));
}

As you can see, it just looks at the first 6 characters of the SQL to
determine whether to filter that out depending on what flags are on or
off...

Samuel Doyle

unread,
Sep 29, 2009, 2:41:12 PM9/29/09
to log4...@googlegroups.com
Really odd, especially when I do see updates just not inserts with the flag set.
I'll do some more debugging when I have time freed up.

Thanks
Reply all
Reply to author
Forward
0 new messages