How do I change the Hibernate logging level?
Asked Answered
H

4

17

How can I change the Hibernate logging level programmatically?

Himes answered 11/5, 2009 at 7:15 Comment(0)
W
16

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.

Whelan answered 11/5, 2009 at 7:43 Comment(2)
(Logger) LoggerFactory.getLogger()Electrocardiogram
And if you want to print parameter values additionally: ((org.apache.log4j.Logger) LoggerFactory.getLogger("org.hibernate.type")).setLevel(Level.TRACE);Sturgeon
E
14

You can use standard log4j functionality:

Logger.getLogger("org.hibernate").setLevel(Level.<what level you require>);
Engelhart answered 11/5, 2009 at 7:47 Comment(0)
R
0

Use Log4j functionality:

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

Logger.getLogger("org.hibernate").setLevel(Level.<what you want>);
Rinse answered 1/4, 2017 at 5:42 Comment(0)
K
0

If using JPA, you can add: <property name="eclipselink.logging.level" value="[LOG LEVEL]" /> to your persistence.xml.

Source: https://eclipse.dev/eclipselink/documentation/2.4/jpa/extensions/p_logging_level.htm

Krystenkrystin answered 10/2 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.