Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the log from specific class/jar via logback.xml

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> 
like image 571
Alagammal P Avatar asked Nov 20 '17 17:11

Alagammal P


People also ask

How do I disable Logback log?

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.

How do you filter Logback logs?

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.

How do I specify the path for Logback XML?

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.


1 Answers

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.

like image 111
glytching Avatar answered Sep 19 '22 05:09

glytching