简体   繁体   中英

How do I change the Hibernate logging level?

如何以编程方式更改Hibernate日志记录级别?

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.

您可以使用标准的log4j功能:

Logger.getLogger("org.hibernate").setLevel(Level.<what level you require>);

Use Log4j functionality:

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

Logger.getLogger("org.hibernate").setLevel(Level.<what you want>);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM