bug in log4jdbc?

207 views
Skip to first unread message

rvelosoo

unread,
Feb 1, 2012, 8:12:41 PM2/1/12
to log4jdbc
After i plugged log4jdbc into my connections, i started to see these
messages in the error logs:

"2012-02-01 09:51:00 - ERROR ajp-8009-9 jdbc.sqltiming - 10.
Connection.setAutoCommit(false)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last
packet successfully received from the server was 55,923,403
milliseconds ago. The last packet sent successfully to the server was
55,923,415 milliseconds ago. is lonn
ger than the server configured value of 'wait_timeout'. You should
consider either expiring and/or testing connection validity before use
in your application, increasing the server configured values for
client timeouts, or using thee
Connector/J connection property 'autoReconnect=true' to avoid
this problem."

It basically repeats these messages in different classes:
jdbc.sqlonly, jdbc.sqltiming and jdbc.audit.

I already have autoReconnect set to true. I suspect the problem is
that log4jdbc is not respecting testOnBorrow=”true”
validationQuery=”select 1″

1/ Why did this error stop appearing after i enabled log4jdbc
2/ How can i avoid printing duplicate error messages


this is my config on spring:

<bean id="parentDataSource"
class="org.apache.commons.dbcp.BasicDataSource" abstract="true">
<property name="driverClassName"
value="net.sf.log4jdbc.DriverSpy"/>
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="initialSize" value="5"/>
<property name="validationQuery" value="select 1" />
<property name="defaultAutoCommit" value="false" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="10" />
<property name="maxWait" value="15000" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="300" />
<property name="testOnBorrow" value="true" />
</bean>

Arthur Blake

unread,
Feb 1, 2012, 8:32:48 PM2/1/12
to log4...@googlegroups.com
On Wed, Feb 1, 2012 at 8:12 PM, rvelosoo <rvel...@gmail.com> wrote:
After i plugged log4jdbc into my connections, i started to see these
messages in the error logs:


All connection properties are passed verbatim to the real driver.

I've no idea why that is occurring.  It is possible that this was already occurring anyway, but the application was just suppressing the exception.  log4jdbc gets and logs the exception before the application does, so if the application is not showing you certain exceptions, log4jdbc can show them to you anyway.  I ran into this type of scenario in a different context before and I had to add a special option to make log4jdbc suppress certain kinds of exceptions.

rvelosoo

unread,
Feb 2, 2012, 1:59:53 AM2/2/12
to log4jdbc
mmm, shouldnt i see the "select 1" validation queries in the logs as
well? How can i avoid the triple logging of this exception? since i
only need jdbc.sqltiming, im setting the other log levels to FATAL to
supress the log mesg. Also, how can i suppress the logging of this
exception only? (that would be the best)


On Feb 1, 5:32 pm, Arthur Blake <arthur.bl...@gmail.com> wrote:

rvelosoo

unread,
Feb 2, 2012, 3:34:51 AM2/2/12
to log4jdbc
Btw, any change you can suppress the logging of exceptions and let the
application do that? or at least an option for that.. thanks

Arthur Blake

unread,
Feb 2, 2012, 10:29:33 AM2/2/12
to log4...@googlegroups.com
On Thu, Feb 2, 2012 at 3:34 AM, rvelosoo <rvel...@gmail.com> wrote:
Btw, any change you can suppress the logging of exceptions and let the
application do that? or at least an option for that.. thanks


It's probably a good idea to have an option to suppress logging of exceptions entirely-- but not something I will get around to adding any time soon.

If you want to modify your copy of log4jdbc to suppress a specific SQL exception,  http://code.google.com/p/log4jdbc/source/detail?r=86  is an example of where it was done in another context. 

rvelosoo

unread,
Feb 2, 2012, 1:06:24 PM2/2/12
to log4jdbc
yeah, that would be good, meanwhile im stuck on using ExpressionFilter
in log4j

On Feb 2, 7:29 am, Arthur Blake <arthur.bl...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages