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?

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

Comments

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)

4 Comments

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)
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.
@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.
@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
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.

Comments

0

with wireshark you can easily see the full mysql sentences

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.