Hibernate suppress info messages

守給你的承諾、 提交于 2020-01-11 10:46:14

问题


So I am not very experience in Java and I am creating a simple test project with Hibernate but I am gettinga lot of INFO messages on the console that I want to suppress. I am creating a Java SE program in Eclipse.

Now as I think I understand it then I need to control this in a log4j.properties file, and I seem to have found the appropiate config to use, but the problem is that it appears that it makes no difference!

My guess is that my log4j.properties file is somehow not being read. But all the details I have found say to place in in the root of my src directory, but it appears not to make any difference. And I have tried placing it in other places in my classpath but all with no luck.

Can somebody help me track down the issue and resolve this?

I had a similar issue last week with a jndi.properties files while using JMS. I eventually resolved that by I am guessing that I am doing something wrong in general. So any tips would be appreciated on where to place config/properties files.

Thanks.


回答1:


log4j logging hierarchy order

OFF
FATAL
ERROR
WARN
INFO
DEBUG
TRACE
ALL

To suppress info messages ,you need to make log4j.properties as

#rootlogger specs
log4j.rootLogger=ERROR, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

set any other logger as OFF



来源:https://stackoverflow.com/questions/11723030/hibernate-suppress-info-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!