In my application I use Java, Hibernate.
Logging : I use logback.xml
Can anyone suggest if there is a way to disable the logs from the below specific class from Hibernate jar.
LOGGER to be removed from the specific class : ERROR o.h.e.jdbc.spi.SqlExceptionHelper
logback.xml:
<configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern> %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </Pattern> </layout> </appender> <logger name="org.springframework" level="error" additivity="false"> <appender-ref ref="STDOUT" /> </logger> <root level="error"> <appender-ref ref="STDOUT" /> </root> </configuration>
Logback does not allow logging to be disabled from the command line. However, if the configuration file allows it, you can set the level of loggers on the command line via a Java system property.
In logback-classic, filters can be added to Appender instances. By adding one or more filters to an appender, you can filter events by arbitrary criteria, such as the contents of the log message, the contents of the MDC, the time of day or any other part of the logging event.
You may specify the location of the default configuration file with a system property named "logback. configurationFile". The value of this property can be a URL, a resource on the class path or a path to a file external to the application.
Add the following to your logback.xml
configuration file:
<logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="OFF"/>
The instruction: level="OFF"
tells Logback to disable all log output for a given logger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With