#32 Logging

closed
nobody
None
4
2007-03-15
2007-02-02
Maxim Senin
No

I read the documentation but am unable to disable logging.

Messages like
09:38:01,996 INFO [STDOUT] 45147669 [http-0.0.0.0-8080-1] DEBUG com.mchange.v2.resourcepool.BasicResourcePool - trace com.mchange.v2.resourcepool.BasicResourcePool@fd2e1f [managed: 3, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@307ae3)

are being logged all the time.

I am using c3p0 with hibernate, and I have log4j in the classpath.

In hibernate.cfg.xml I enable hibernate to use c3p0 by setting these properties:

<property name="hibernate.c3p0.initial_pool_size">10</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.timeout">5000</property> <!-- seconds before idle connection expires -->
<property name="hibernate.c3p0.idle_test_period">300</property><!-- check connection alive -->
<property name="hibernate.c3p0.acquire_increment">2</property>

Unsure how to disable loging, I added these in log4j.properties:
log4j.logger.com.mchange=NONE
log4j.logger.com.mchange.v2.c3p0=NONE
#log4j.logger.com.mchange.v2.c3p0.SQLWarnings=NONE

I also created c3p0.properties file:
###########################################################
# c3p0 property file
###########################################################

#enforce Log4J logging
com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog

#com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=OFF
com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=SEVERE
#com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=CONFIG

maxStatements=280
maxStatementsPerConnection=70

#com.mchange.v2.c3p0.SQLWarnings=NONE

They are all located in the root(/) of the application's classpath.

The settings in hibernate.xfg.xml definitely take effect.

Is there a way to turn c3p0 logging off or change it to INFO instead of DEBUG without rebuilding the jar file with c3p0.debug=false and c3p0.trace=off?

Thanks!
Maxim

Discussion

  • Maxim Senin
    Maxim Senin
    2007-02-02

    • priority: 5 --> 4
     
  • Steve Waldman
    Steve Waldman
    2007-02-04

    Logged In: YES
    user_id=175530
    Originator: NO

    Hi... Try setting log4j.logger.com.mchange.v2.resourcepool=INFO (or better yet, log4j.logger.com.mchange=INFO). I think your problem was just your use of NONE. log4j.properties wants OFF, not NONE, for no logging at all.

    Generally speaking, c3p0 stuff expects to be at INFO or higher, and is very verbose at DEBUG levels. Normal users (using log4j) should set logging to INFO or WARN (INFO or WARNING using jdk14 logging).

    If you are logging to log4j, the com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL stuff has no effect.

    Good luck!

     
  • Maxim Senin
    Maxim Senin
    2007-02-06

    Logged In: YES
    user_id=1708920
    Originator: YES

    Thanks. I tried that but it didn't work.
    I think the secret is in the log entries: the entry begins with INFO, but after the IP address you see a DEBUG-level entry from BasicResourcePool.
    I downloaded the source code and rebuilt the build.xml itno JAR file with c3p0.debug and c3p0.trace both set to false. Now I don't get any messages below INFO level.

     
  • Steve Waldman
    Steve Waldman
    2007-03-15

    Logged In: YES
    user_id=175530
    Originator: NO

    I don't know why normal filtering to INFO level didn't work for you, but I've not heard of others having trouble configuring c3p0 logging via their logging libraries, so I'm calling this resolved, for now. Let me know if you think there's something I should get back to.

     
  • Steve Waldman
    Steve Waldman
    2007-03-15

    • status: open --> closed