java 通过 logback.xml 禁用来自特定类/jar 的日志
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47397442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable the log from specific class/jar via logback.xml
提问by Alagammal P
In my application I use Java, Hibernate.
在我的应用程序中,我使用 Java、Hibernate。
Logging : I use logback.xml
日志记录:我使用 logback.xml
Can anyone suggest if there is a way to disable the logs from the below specific class from Hibernate jar.
任何人都可以建议是否有办法从 Hibernate jar 中禁用以下特定类的日志。
LOGGER to be removed from the specific class: ERROR o.h.e.jdbc.spi.SqlExceptionHelper
要从特定类中删除的 LOGGER:ERROR ohejdbc.spi.SqlExceptionHelper
logback.xml:
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>
回答by glytching
Add the following to your logback.xml
configuration file:
将以下内容添加到您的logback.xml
配置文件中:
<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.
指令:level="OFF"
告诉 Logback 禁用给定记录器的所有日志输出。
回答by gtosto
In your logback.xml configuration adding the following element should work
在您的 logback.xml 配置中添加以下元素应该可以工作
<logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="OFF"/>
<logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="OFF"/>