Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Hibernate over-verbose logging

Reply
Thread Tools

Hibernate over-verbose logging

 
 
Steven J. Sobol
Guest
Posts: n/a
 
      09-26-2006
Is there any way to disable logging in Hibernate? A lot of what is logged is
useless to me...


--
Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows
Apple Valley, California PGP:0xE3AE35ED

It's all fun and games until someone starts a bonfire in the living room.
 
Reply With Quote
 
 
 
 
Jean-Francois Briere
Guest
Posts: n/a
 
      09-26-2006
Have a look at:
http://www.hibernate.org/hib_docs/v3...ration-logging

In your log4j properties file you could do:

log4j.logger.org.hibernate=error

but it's a good idea to keep the SQL:

log4j.logger.org.hibernate.SQL=debug

Regards

 
Reply With Quote
 
 
 
 
Steven J. Sobol
Guest
Posts: n/a
 
      09-26-2006
In article <(E-Mail Removed) .com>, Jean-Francois Briere wrote:
> Have a look at:
> http://www.hibernate.org/hib_docs/v3...ration-logging
>
> In your log4j properties file you could do:
>
> log4j.logger.org.hibernate=error
>
> but it's a good idea to keep the SQL:
>
> log4j.logger.org.hibernate.SQL=debug


I'm still getting all sorts of crap: my log4j.properties contains

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=error, stdout

log4j.logger.org.hibernate=error

but I still get

Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/stevesobol/gallery/Photo.hbm.xml
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.stevesobol.gallery.Photo -> photos
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
INFO: Hibernate connection pool size: 20
Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
INFO: autocommit mode: false
Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://amethyst.justthe.net/gallery
Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
INFO: connection properties: {user=sjsobol, password=****}
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 4.0.26-Max
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
Sep 26, 2006 7:23:47 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Sep 26, 2006 7:23:47 AM org.hibernate.transaction.TransactionFactoryFactor y buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Sep 26, 2006 7:23:47 AM org.hibernate.transaction.TransactionManagerLookup Factory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 26, 2006 7:23:48 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Sep 26, 2006 7:23:48 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Sep 26, 2006 7:23:48 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache -failsafe.xml found in the classpath: jar:file:/C:/Data/@Common/lib/ehcache-1.2beta1.jar!/ehcache-failsafe.xml
Sep 26, 2006 7:23:49 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Sep 26, 2006 7:23:49 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries

I'm new to log4j. Do I have to separately configure each class doing logging?

(I'm trying that too, and it doesn't seem to work)


> Regards
>



--
Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows
Apple Valley, California PGP:0xE3AE35ED

It's all fun and games until someone starts a bonfire in the living room.
 
Reply With Quote
 
jukka.tamminen@pp.inet.fi
Guest
Posts: n/a
 
      09-27-2006
Hi Steven

The answer to you question lies in the log4j.properties file.

In the file you tell the logger the level of logging. These are :
DEBUG, INFO, WARN, ERROR, FATAL.
The verbousness dercreases from rigth to left on this list.

I was able to get almos everything away, when I changed "info" to
"fatal"

Hope this helsp you

-jukkaT-

Here is my changed file:


### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.Patte rnLayout
#log4j.appender.file.layout.ConversionPattern=%d{A BSOLUTE} %5p %c{1}:%L
- %m%n

### set log levels - for more verbose logging change 'info' to 'debug'
###

log4j.rootLogger=warn, stdout

log4j.logger.org.hibernate=fatal
#log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManag erConnectionProvider=trace


Steven J. Sobol kirjoitti:

> In article <(E-Mail Removed) .com>, Jean-Francois Briere wrote:
> > Have a look at:
> > http://www.hibernate.org/hib_docs/v3...ration-logging
> >
> > In your log4j properties file you could do:
> >
> > log4j.logger.org.hibernate=error
> >
> > but it's a good idea to keep the SQL:
> >
> > log4j.logger.org.hibernate.SQL=debug

>
> I'm still getting all sorts of crap: my log4j.properties contains
>
> ### direct log messages to stdout ###
> log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
> log4j.appender.stdout.Target=System.out
> log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
> log4j.appender.stdout.layout.ConversionPattern=%d{ ABSOLUTE} %5p %c{1}:%L - %m%n
> log4j.rootLogger=error, stdout
>
> log4j.logger.org.hibernate=error
>
> but I still get
>
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
> INFO: Hibernate 3.0.5
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
> INFO: loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
> INFO: using CGLIB reflection optimizer
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Environment <clinit>
> INFO: using JDK 1.4 java.sql.Timestamp handling
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration configure
> INFO: configuring from resource: /hibernate.cfg.xml
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration getConfigurationInputStream
> INFO: Configuration resource: /hibernate.cfg.xml
> Sep 26, 2006 7:23:45 AM org.hibernate.cfg.Configuration addResource
> INFO: Mapping resource: com/stevesobol/gallery/Photo.hbm.xml
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
> INFO: Mapping class: com.stevesobol.gallery.Photo -> photos
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration doConfigure
> INFO: Configured SessionFactory: null
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
> INFO: processing extends queue
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
> INFO: processing collection mappings
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
> INFO: processing association property references
> Sep 26, 2006 7:23:46 AM org.hibernate.cfg.Configuration secondPassCompile
> INFO: processing foreign key constraints
> Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
> INFO: Using Hibernate built-in connection pool (not for production use!)
> Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
> INFO: Hibernate connection pool size: 20
> Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
> INFO: autocommit mode: false
> Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
> INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://amethyst.justthe.net/gallery
> Sep 26, 2006 7:23:46 AM org.hibernate.connection.DriverManagerConnectionPr ovider configure
> INFO: connection properties: {user=sjsobol, password=****}
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: RDBMS: MySQL, version: 4.0.26-Max
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
> Sep 26, 2006 7:23:47 AM org.hibernate.dialect.Dialect <init>
> INFO: Using dialect: org.hibernate.dialect.MySQLDialect
> Sep 26, 2006 7:23:47 AM org.hibernate.transaction.TransactionFactoryFactor y buildTransactionFactory
> INFO: Using default transaction strategy (direct JDBC transactions)
> Sep 26, 2006 7:23:47 AM org.hibernate.transaction.TransactionManagerLookup Factory getTransactionManagerLookup
> INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Automatic flush during beforeCompletion(): disabled
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Automatic session close at end of transaction: disabled
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: JDBC batch size: 15
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: JDBC batch updates for versioned data: disabled
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Scrollable result sets: enabled
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: JDBC3 getGeneratedKeys(): enabled
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Connection release mode: null
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Maximum outer join fetch depth: 2
> Sep 26, 2006 7:23:47 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Default batch fetch size: 1
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Generate SQL with comments: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Order SQL updates by primary key: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
> INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
> Sep 26, 2006 7:23:48 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
> INFO: Using ASTQueryTranslatorFactory
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Query language substitutions: {}
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Second-level cache: enabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Query cache: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory createCacheProvider
> INFO: Cache provider: org.hibernate.cache.EhCacheProvider
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Optimize cache for minimal puts: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Structured second-level cache entries: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Statistics: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Deleted entity synthetic identifier rollback: disabled
> Sep 26, 2006 7:23:48 AM org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Default entity-mode: pojo
> Sep 26, 2006 7:23:48 AM org.hibernate.impl.SessionFactoryImpl <init>
> INFO: building session factory
> Sep 26, 2006 7:23:48 AM net.sf.ehcache.config.Configurator configure
> WARNING: No configuration found. Configuring ehcache from ehcache -failsafe.xml found in the classpath: jar:file:/C:/Data/@Common/lib/ehcache-1.2beta1.jar!/ehcache-failsafe.xml
> Sep 26, 2006 7:23:49 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
> INFO: Not binding factory to JNDI, no JNDI name configured
> Sep 26, 2006 7:23:49 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
> INFO: Checking 0 named queries
>
> I'm new to log4j. Do I have to separately configure each class doing logging?
>
> (I'm trying that too, and it doesn't seem to work)
>
>
> > Regards
> >

>
>
> --
> Steve Sobol, Professional Geek ** Java/VB/VC/PHP/Perl ** Linux/*BSD/Windows
> Apple Valley, California PGP:0xE3AE35ED
>
> It's all fun and games until someone starts a bonfire in the living room.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate LazyInitializationException in web application Struts asMVC, Spring as IOC and Hibernate as ORM layer Amit Jain Java 7 04-27-2009 10:27 AM
HIBERNATE - java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration Eleanna Skouta Java 2 12-09-2008 02:09 AM
Hibernate cannot find hibernate.cfg.xml jstorta Java 1 01-19-2008 01:45 PM
Hibernate Syncronizer now generates code for Hibernate 3.0 msenin@covad.net Java 0 07-14-2005 05:47 AM
[HIBERNATE] [EVALUATION] - Gavin King Censors Hibernate Forum Ilias Lazaridis Java 0 12-27-2004 04:26 AM



Advertisments