Hikaricp: SLF4J clarification

Created on 22 Mar 2015  ·  4Comments  ·  Source: brettwooldridge/HikariCP

We are getting the following when our program starts up

2015-03-22 20:01:27 [WARN] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2015-03-22 20:01:27 [WARN] SLF4J: Defaulting to no-operation (NOP) logger implementation
2015-03-22 20:01:27 [WARN] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Can you clarify what NOP means in this context? Does it mean "going to log the way it managed to log that warning" or does it mean "not going to log anything at all"?

Assuming the first, is there any way I can shut that warning up, with the minimum of extra hassle?

question

All 4 comments

This warning is from SLF4J and not directly from HikariCP. Hikari uses the SLF4J logging API and when you see the above warning it means that you do not have any SLF4J implementation/binding in your class path. In that case you will not see any log output from HikariCP at all (thus no-operation).

To fix the warning (and see logs from Hikari) you need to explicitly add a SLF4J implementation/binding of your choice to your class path. See section "Binding with a logging framework at deployment time" at http://www.slf4j.org/manual.html

The link from that warning tells me to download one of a selection of jar files from a page that doesn't contain those jar files, and I can't see anything that jumps out at me from the link you gave me.

Basically our code is a plugin to some other software; as a plugin we are given a Logger object and ideally should be passing our logging to that

I know this sounds very "plz give me teh codez" but are you able to tell me what I need to do to integrate whatever I need to integrate so users of my plugin get this logged properly? This is using maven as a build system. The docs seems to be oriented towards writing things using SLF4J, not using things that use it.

You can't tell HikariCP to use a specific Logger object, but as your software uses java.util.logging.Logger you can configure SLF4J to also log through normal Java logging. To do so you have to place slf4j-jdk14 in your class path.

<dependency> 
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-jdk14</artifactId>
  <version>1.7.10</version>
</dependency>

The above is actually mentioned in the link I gave you ;-) See: http://www.slf4j.org/manual.html#projectDep

ah, I didn't know the manual was one loooong page; I assumed the links on the left was the table of contents and I couldn't find anything relevant. Cheers, that's perfect

Was this page helpful?
0 / 5 - 0 ratings