2

Im using the JOOQ library to generate and perform SQL queries. For debugging reasons I want to see what queries exactly are performed without looking at the changing database every time. I think the jooq framework should show lots of informations about queries and their effects if the log level is set to debug. I use log4j2 for logging, and it is set to debug using the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="DEBUG" packages="ch.fhnw.ima.doggait">
    <appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </appenders>

    <loggers>
        <root level="DEBUG">
            <appender-ref ref="Console"/>
        </root>
    </loggers>
</configuration>

Unfortunally It looks like JOOQ uses another logger, which is set to info. This is an example output:

2015-09-29 10:15:04,064 DEBUG Shutdown.. 2015-09-29 10:15:04,065 DEBUG LoggerCo.. 2015-09-29 10:15:04,111 DEBUG Using d... 10:15:04.116 [Test worker] DEBUG ch.fh.. Sep 29, 2015 10:15:04 AM org.jooq.tools.JooqLogger info INFORMATION: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....

You can see the first few lines are logged in debug mode by log4j2, but Jooq uses JooqLogger in level info. I load both libraries using gradle:

compile group: 'com.google.inject',             name: 'guice-parent',               version: '3.0'
compile group: 'com.google.inject.extensions',  name: 'guice-persist',              version: '3.0'
compile group: 'org.hibernate',                 name: 'hibernate-entitymanager',    version: '4.3.8.Final'
compile group: 'com.h2database',                name: 'h2',                         version: '1.4.185'
compile group: 'org.apache.commons',            name: 'commons-math3',              version: '3.2'
compile group: 'org.apache.logging.log4j',      name: 'log4j-core',                 version: '2.0.2'
compile group: 'org.apache.logging.log4j',      name: 'log4j-api',                  version: '2.0.2'
compile group: 'org.hamcrest',                  name: 'hamcrest-all',               version: '1.3'
compile group: 'org.apache.pdfbox',             name: 'pdfbox',                     version: '1.8.10'
compile group: 'postgresql',                    name:'postgresql',                  version:'9.0-801.jdbc4'
compile group: 'org.jooq',                      name:'jooq',                        version:'3.6.3'
compile group: 'org.jooq',                      name:'jooq-meta',                   version:'3.6.3'
compile group: 'org.jooq',                      name:'jooq-codegen',                version:'3.6.3'

testCompile 'junit:junit:4.11'

Does somebody know why jooq does not use log4j2 as the default logger, or how I can set it to log in debug level?

TardigradeX
  • 707
  • 11
  • 29

2 Answers2

2

jOOQ is still using log4j 1.2 as a default, internally. You should use that version (for now), or slf4j instead.

There are a couple of feature requests to improve these dependencies in jOOQ:

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Alright. Thanks for the clarification. I switched to log4j 1.2 which works. Hopefully the requests will be resolved soon. – TardigradeX Sep 29 '15 at 11:58
0

I know it's little late, but I found the same problem and I fixed it with the help of apache itself. You can include this adapter in your classpath, it bridges log4j2 with log4j 1.2

  • log4j-1.2-api-2.6.1.jar

But, you must not have log4j 1.2 jars or config files in your classpath. In short, do everything with log4j2 and just include above jar.

For further reading : http://logging.apache.org/log4j/2.x/faq.html#which_jars

This SO question helped me : Configuring log4j2 and log4j using a single log4j2 xml file

Community
  • 1
  • 1
theGamblerRises
  • 686
  • 1
  • 11
  • 27