I have a Spring Boot application with the following setting in logback-spring.xml
<logger name="org.hibernate.sql" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
But this doesn't log the generated SQL unless I change sql
to uppercase like this
<logger name="org.hibernate.SQL" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
which then produces log statements like this
...org.hibernate.SQL : select count(disabled0_.user)
Also worth noting is that IntelliJ doesn't link to anything when I hover over SQL
in the logger name. It links to the package when hovering overorg.hibernate
but stops at SQL
. But it does link to other more specific classes like this one
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" additivity="false" >
<appender-ref ref="CONSOLE"/>
</logger>
in that one, hovering over BasicBinder
does link to the class, and results in statements like
o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR]
Why does SQL
have to be uppercase to work?
I am using spring-boot-starter-data-jpa:1.5.10.RELEASE
SQL has to be in uppercase, because the logger name is case-sensitive. See this answer.
IntelliJ can't link to the class, because it's not actually a class, just the name of the Hibernate logger. By convention, logger names are the class name, but that's not a requirement, they can be any string.