1
votes

In my java code, the following line

getHibernateTemplate().save(billingCompany); 

is printing a logger message

2013-11-11 14:05:20,962 INFO [STDOUT] Hibernate: insert into billing_log_company (COMPANY_ID, BILLING_LOG_ID) values (?, ?)

But actually I need DEBUG in place of INFO like this:

2013-11-11 14:05:20,962 DEBUG [STDOUT] Hibernate: insert into billing_log_company (COMPANY_ID, BILLING_LOG_ID) values (?, ?)

I mean that we are not writing logger.info. logger.debug etc.. getHibernateTemplate().save(billingCompany) is printing that logger msg in INFO mode.

3

3 Answers

2
votes

Hibernate messages it self is in hibernate source code, you can't change that. However, you can change Hibernate log level to warn or debug. but this will fill your console with a lot of logs

In your log properties file change

log4j.logger.org.hibernate=info

to

log4j.logger.org.hibernate=debug

or

log4j.logger.org.hibernate=warn
0
votes

I don't understand your question. If you want DEBUG rather than INFO in the spring hibernate template then you'll have to change their source code. If you want to use DEBUG in our own code, just use

logger.debug(...)

0
votes

Benjamin was clear in his approach.

You must be using some api to log like log4j, promatter... most logger api has different methods for logging different scenarios.

Take log4j for example,

static Logger loggerfile = Logger.getLogger(ThisClass.class.getName());//creating logger instance
loggerFile.debug("debug");
loggerFile.info("info");
loggerFile.error("erre");