KimJaeJoong2 / log4jdbc-log4j2

Automatically exported from code.google.com/p/log4jdbc-log4j2
0 stars 0 forks source link

Batch statements are not logged when dumpSqlFilteringOn #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Enable filtering (eg log4jdbc.dump.sql.insert to false)
2. Perform a batch operation (eg a select)

What is the expected output? What do you see instead?
Expect to see the select logged.
Instead, nothing's logged.

What version of the product are you using? On what operating system?
log4jdbc-log4j2-jdbc4.1-1.16.

Please provide any additional information below.
In Slf4jSpyLogDelegator.sqlOccurred, if the filtering is on, it calls 
shouldSqlBeLogged(). This method checks that it starts with 
select/insert/update etc. But the batched SQL starts with "batching" and so it 
never matches.

Note that this is not a problem if the filtering is off (due, as the 
shouldSqlBeLogged() isn't called).

Please see patch attached, with two tests. One with filtering off (SQL is 
logged as expected).  The other has filtering on, and the SQL is not logged. 

Original issue reported on code.google.com by jst...@tnsi.com on 28 May 2014 at 5:12

Attachments:

GoogleCodeExporter commented 8 years ago
This is a known bug inherited from the original log4jdbc library. The original 
developer stated: "the whole idea of filtering on the type of SQL probably was 
a bad idea as it's very hard to do that reliably when the SQL gets complex."
See https://code.google.com/p/log4jdbc/issues/detail?id=45

Your problem was also reported in the original library: 
https://code.google.com/p/log4jdbc/issues/detail?id=39

If you can think of an effective way to perform the filtering, I'll be glad to 
implement it. Otherwise, this will be a "won't fix" :/

Original comment by frederic...@gmail.com on 4 Jun 2014 at 12:05

GoogleCodeExporter commented 8 years ago

Original comment by frederic...@gmail.com on 24 Jul 2014 at 11:04