Hibernate log4j无法识别log4j.properties

时间:2022-07-14 22:04:15

I have a hibernate standard java application (not a webapp). Logging already works by default. I would like to see the parameters passed in the sql queries. I have researched that in order to that I need to enable logging. It seems as if hibernate uses slf4j. I have downloaded that jar and its accompanying slf4j-log4j jar. I have added these jars to the classpath. I have also added a log4j.properties to the root of the eclipse project.

我有一个hibernate标准的java应用程序(不是webapp)。默认情况下,日志记录已经有效我想看看sql查询中传递的参数。我已经研究过,为此我需要启用日志记录。似乎hibernate使用slf4j。我已经下载了那个jar及其附带的slf4j-log4j jar。我已将这些jar添加到类路径中。我还在eclipse项目的根目录中添加了一个log4j.properties。

I can't seem to have the project recognize that it needs to use slf4j and its properties file.

我似乎无法让项目认识到它需要使用slf4j及其属性文件。

Do I need to add a reference in my hibernate.cfg.xml?

我是否需要在hibernate.cfg.xml中添加引用?

1 个解决方案

#1


0  

Make sure you have the property hibernate.show_sql set to true.

确保将属性hibernate.show_sql设置为true。

format_sql set to true will make the SQL be formatted a bit more pretty.

将format_sql设置为true将使SQL格式化得更漂亮。

You may also need to log on TRACE level.

您可能还需要登录TRACE级别。

For more details have a look here or here.

有关详细信息,请查看此处或此处。

#1


0  

Make sure you have the property hibernate.show_sql set to true.

确保将属性hibernate.show_sql设置为true。

format_sql set to true will make the SQL be formatted a bit more pretty.

将format_sql设置为true将使SQL格式化得更漂亮。

You may also need to log on TRACE level.

您可能还需要登录TRACE级别。

For more details have a look here or here.

有关详细信息,请查看此处或此处。