-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Console or SQL logs are not logged with log4j
PostPosted: Thu May 29, 2008 4:32 am 
Newbie

Joined: Thu May 29, 2008 4:17 am
Posts: 1
Hibernate version: 3

Name and version of the database you are using:db2 8

The generated SQL (show_sql=true): true

Debug level Hibernate log excerpt:debug

Hi,

I have configured log4j with hibernate and still i get all the hibernate messages on console and is not being logged to the log file configured.

The messages sent by my application is only logged in my log file. How do i include all the messages of hibernate and SQL (displayed on console with the param show_sql=true) to my created file.

Is there a way to get the actual binded parameters insted of '?" with SQL statements

1. Log4j jar has been included.

2. log4j.properties is in classpath

3. Contents of log4j
-----------------------------------
log4j.appender.fileapp=org.apache.log4j.FileAppender
log4j.appender.fileapp.File=/home/xxxx/Libra/Libra_TSVWriter_Logs.txt
log4j.appender.fileapp.layout=org.apache.log4j.PatternLayout
log4j.appender.fileapp.layout.ConversionPattern=%d{ISO8601}|%p|%F|%M|%L|%m%n

log4j.rootLogger=debug, fileapp
log4j.logger.org.hibernate=debug

4. hibernate.cfg.xml
--------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="connection.username">uid</property>
<property name="connection.password">pass</property>

<property name="connection.driver_class">
com.ibm.db2.jcc.DB2Driver
</property>
<property name="connection.url">
jdbc:db2://xxxxx:xxxx/xxxx
</property>
<mapping resource="com/xxxx/libra/or/LibraHcAssess.hbm.xml"></mapping>
<mapping resource="com/xxxx/libra/or/LibraProcessMast.hbm.xml"></mapping>
</session-factory>

</hibernate-configuration>

5.Startup messages
------------------------------
May 29, 2008 1:57:17 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
May 29, 2008 1:57:18 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 29, 2008 1:57:18 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
May 29, 2008 1:57:18 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 29, 2008 1:57:18 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
May 29, 2008 1:57:18 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
May 29, 2008 1:57:19 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/xxxx/libra/or/LibraHcAssess.hbm.xml
May 29, 2008 1:57:19 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.xxxx.libra.or.LibraHcAssess -> LIBRA_HC_ASSESS
May 29, 2008 1:57:19 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : com/xxxx/libra/or/LibraProcessMast.hbm.xml
May 29, 2008 1:57:19 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.xxxx.libra.or.LibraProcessMast -> LIBRA_PROCESS_MAST
May 29, 2008 1:57:19 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
May 29, 2008 1:57:19 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.xxxx.libra.or.LibraProcessMast.setDBTableLibraHcAssess -> LIBRA_HC_ASSESS
May 29, 2008 1:57:19 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 29, 2008 1:57:19 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 29, 2008 1:57:19 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
May 29, 2008 1:57:20 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.ibm.db2.jcc.DB2Driver at URL: jdbc:db2://ptulb015:60060/PIGTSINI
May 29, 2008 1:57:20 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=nycikcp, password=****}
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: DB2/SUN64, version: SQL08026
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: IBM DB2 JDBC Universal Driver Architecture, version: 2.9.31
May 29, 2008 1:57:21 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DB2Dialect
May 29, 2008 1:57:21 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
May 29, 2008 1:57:21 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
May 29, 2008 1:57:21 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
May 29, 2008 1:57:21 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
May 29, 2008 1:57:21 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 29, 2008 1:57:21 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2008 1:15 pm 
Newbie

Joined: Fri Sep 07, 2007 1:39 pm
Posts: 2
I see the same effect. I'm using java.util.logging with this simple config file:

Code:
handlers = java.util.logging.FileHandler
.level = ALL
java.util.logging.FileHandler.pattern = java.log
org.hibernate.level=INFO


and enable it using

Code:
$ java -Djava.util.logging.config.file=src/logging.properties ...


and continue to see Hibernate log output go to the console. Other loggers (not shown) comply with the config file by logging their statements to java.log.

I have slf4j-api-1.5.3.jar and slf4j-simple-1.5.3.jar on the classpath, which may or may not bear on the problem.

I'm not too proud for pity. Anyone?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2008 1:40 pm 
Newbie

Joined: Fri Sep 07, 2007 1:39 pm
Posts: 2
Answering my own question, and for posterity:

To tie slf4j to java.util.logging, put slf4j-jdk14-1.5.3.jar on the runtime classpath, not slf4j-simple-1.5.3.jar. Adjust the version of these jars to your needs, of course.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.