I'd recommend doing this by adding a property source to the environment that contains the logging.level.org.hibernate
property set to WARN
.
To do so, you can use META-INF/spring.factories
to register an implementation of EnvironmentPostProcessor
. The spring.factories
file is a properties file. The keys are the fully qualified class name of the implemented interface. In this case it's org.springframework.boot.env.EnvironmentPostProcessor
and the value should be the fully qualified name of your implementation. The contents would like something like this:
org.springframework.boot.env.EnvironmentPostProcessor=com.example.HibernateLoggingEnvironmentPostProcessor
In your EnvironmentPostProcessor
implementation you should add a PropertySource
to the Environment
. That property source should contain a logging.level.org.hibernate
property with a value of WARN
. For example, you could use a MapPropertySource
created using Collections.singletonMap
.