1

Our current project has no log4j jars, we use JDK logging API only. Now i needed to see the values of HQL statements, which are currently displayed with "?","?".

I found a lot of tips, using LOG4J. But no solution found with JDK:---((

I have set the following in logging.properties:

  1. org.hibernate.level=TRACE
  2. org.hibernate.SQL.level = TRACE
  3. .level=TRACE

But it had no effect. If I set the INFO level, so all WARNs, that I send for tests, will NOT be visible. Thus, logging.properties is bound to Java class path

Does anybody have any ideas?

Community
  • 1
  • 1
Kamen Jahr
  • 241
  • 2
  • 7
  • 15

4 Answers4

1

JBoss Logging will look for a System setting with the key org.jboss.logging.provider. What you need to do is to set the system properties with that key with value "jdk", such that Hibernate will use Java logging framework for logging

System.setProperty("org.jboss.logging.provider", "jdk"); 

To log binding parameters in sql, you need one more statement in your logging.properties

org.hibernate.type.descriptor.sql.level=FINEST

You may refer the details from the logging guide of Hibernate http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html

lumion
  • 25
  • 5
0

The authoritative resource on Java JDK logging is the Java Logging Guide : http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html

But generally speaking, JDK logging does not define a TRACE level: http://docs.oracle.com/javase/6/docs/api/java/util/logging/Level.html

Hibernate uses JBoss Logging for its logging. JBoss Logging defines a TRACE level (like most logging libraries other than the JDK); when bridging to JDK logging, JBoss Logging maps TRACE to JDK's FINER level. So you'd want to use =FINER in your config (or =FINEST)

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
Steve Ebersole
  • 9,339
  • 2
  • 48
  • 46
  • Hi, i have tried, to set FINEST with NO effect:-(( if i debug to the org.jboss.logging.BasicLogger. public boolean isTraceEnabled() { return isEnabled(Level.TRACE);, the "false" is returned, because java.util.logging.Logger. public boolean isLoggable(Level level) { if (level.intValue() < levelValue || levelValue == offValue) { return false; } return true; } reeturns "false", because "levelValue" equals to 800 (also INFO) – Kamen Jahr Jun 04 '13 at 07:53
  • Your problem is not Hibernate nor JBoss Logging. You simply are not configuring JDK Logging correctly. I have never used JDK logging (mainly because of stuff like this). So I cannot help you with that. I posted the JDK Logging tool page. I tried reading it, but tbh, it is less than great documentation and I came away with no more knowledge of how to configure JDK Logging via a properties file. – Steve Ebersole Jun 04 '13 at 14:29
  • @KamenJahr As Steve said it looks like the JDK logging is not configured correct. Can you explain how you're configuring it? By default JDK logging looks in the JRE `lib` directory for a `logging.properties` file. You can override that with the `java.util.logging.config.file` system property though. – James R. Perkins Jun 04 '13 at 15:29
  • @ALL you are all right, my logging.properties was not correclty bound in java class path, i don't know currently, what is wrong, but if i load the loggings.properties using the following code, i see the real values of HQLs if i use the FINEST level: public static void loadLoggings(String fullName) throws SecurityException, IOException { InputStream is = null; is = new FileInputStream(fullName); LogManager.getLogManager().readConfiguration(is); }. i have defined such level: org.hibernate.SQL.level =FINEST within properties file. Other level options are set to OFF – Kamen Jahr Jun 05 '13 at 07:31
0

I have encountered the same issue and doesn't want to use another logging facility.

I ended up with following configuration (original question):

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINE
org.hibernate.level=WARN
org.hibernate.SQL.level=FINE

Perhaps not the best one, because it logs sometimes a lot of stuff, but it is working.

Community
  • 1
  • 1
CSchulz
  • 10,882
  • 11
  • 60
  • 114
0

with wireshark you can easily see the full mysql sentences

ejaenv
  • 2,117
  • 1
  • 23
  • 28