gri*_*gon 1 java logging logback
我正在越来越多地记录我的项目,而且我无法抑制我不想要的日志记录.
我正在使用我添加到我的POM安装的Logback.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的日志始终以这三行开头:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Run Code Online (Sandbox Code Playgroud)
谷歌搜索表明这是Eclipse问题,而不是Logback配置问题,但我包括它以防万一我的谷歌搜索误导我.
这是我的logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="com.my.project" level="TRACE"/>
<logger name="o.a.cxf" level="INFO"/>
<logger name="o.a.c" level="INFO"/>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这是我日志的摘录
[INFO] 17:41:53.095 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_DH_anon_WITH_DES_CBC_SHA cipher suite is excluded by the filter.
[INFO] 17:41:53.095 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_RSA_EXPORT_WITH_RC4_40_MD5 cipher suite is included by the filter.
[INFO] 17:41:53.095 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 cipher suite is excluded by the filter.
[INFO] 17:41:53.096 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_RSA_EXPORT_WITH_DES40_CBC_SHA cipher suite is included by the filter.
[INFO] 17:41:53.096 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA cipher suite is included by the filter.
[INFO] 17:41:53.096 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA cipher suite is included by the filter.
[INFO] 17:41:53.096 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA cipher suite is excluded by the filter.
[INFO] 17:41:53.097 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_RC4_128_SHA cipher suite is included by the filter.
[INFO] 17:41:53.103 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_RC4_128_MD5 cipher suite is included by the filter.
[INFO] 17:41:53.103 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_3DES_EDE_CBC_SHA cipher suite is included by the filter.
[INFO] 17:41:53.103 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_3DES_EDE_CBC_MD5 cipher suite is included by the filter.
[INFO] 17:41:53.104 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_DES_CBC_SHA cipher suite is included by the filter.
[INFO] 17:41:53.104 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_WITH_DES_CBC_MD5 cipher suite is included by the filter.
[INFO] 17:41:53.104 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_EXPORT_WITH_RC4_40_SHA cipher suite is included by the filter.
[INFO] 17:41:53.104 DEBUG o.a.c.t.h.HttpsURLConnectionFactory - The TLS_KRB5_EXPORT_WITH_RC4_40_MD5 cipher suite is included by the filter.
Run Code Online (Sandbox Code Playgroud)
我已经通过修改appender中的模式验证了我的logback.xml文件正在被读取.这些变化正在得到尊重.但我希望将"oac"的记录器设置为INFO会抑制这些DEBUG消息.我假设[INFO]也来自Eclipse,后面的DEBUG是实际的记录器级别.
这些记录器由Apache CXF记录.我的项目中有一个依赖项,它具有使用CXF生成的存根代码.当我使用该存根代码来调用Web服务时,会生成这些记录器.我没有编写这些日志记录语句,因此我只能假设它们来自CXF.
另外,当我使用Log4j时,我没有看到这些记录器.我正在尝试学习Logback,因为我被分配来评估它作为团队的可能升级.
虽然它显示o.a.c.t.h.HttpsURLConnectionFactory在日志消息中,但记录器名称实际上并非如此o.a.c.t.h.HttpsURLConnectionFactory. o.a.c...只是全名的缩写.
我认为你应该使用org.apache.cxf,而不是o.a.c和o.a.cxf你的logback.xml