Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the Hibernate logging level?

How can I change the Hibernate logging level programmatically?

like image 267
Abdul Khaliq Avatar asked May 11 '09 07:05

Abdul Khaliq


2 Answers

Hibernate uses SLF4j as it's logging API. Looking at this API I can't find any way to adjust the logging level programatically.

So in my opinion you have to use the underlying runtime logging system directly. This depends on what you have configured. When using log4j this would be something like

import org.apache.log4j.Logger;
import org.apache.log4j.Level;

...    

Logger log = Logger.getLogger("org.hibernate.SQL");
log.setLevel(Level.DEBUG);

But remember that going this way your code is dependent on the underlying logging implementation.

like image 74
rudolfson Avatar answered Sep 28 '22 18:09

rudolfson


You can use standard log4j functionality:

Logger.getLogger("org.hibernate").setLevel(Level.<what level you require>);
like image 39
PaulJWilliams Avatar answered Sep 28 '22 18:09

PaulJWilliams