Jetty 6总是生成调试日志吗? [英] Jetty 6 always generates debug logs?

查看:123
本文介绍了Jetty 6总是生成调试日志吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jetty 6.1.24开发Web服务,并且我的代码像Jetty一样使用slf4j,并且日志记录工作正常.我想做的是从代码而不是从Jetty 获取调试日志(太冗长了),但是我不能阻止它从调试信息中记录日志.有一些系统属性可以设置调试模式(-DDEBUG),但不能设置未调试模式.

I am using Jetty 6.1.24 to develop a Web Service and my code uses slf4j, as Jetty does, and logging is working fine. What I want to do though is get debug logging from my code but not from Jetty (it's too verbose), but I cannot stop it from logging debug info. There are system properties to set debug mode (-DDEBUG), but not to unset debug mode.

通过启动脚本通过设置系统属性'loglevel'来设置我的logback日志级别,这又将其设置在我的resources/logback.xml中:

My logback log level is set by the start script by setting the system property 'loglevel' and this in turn sets it in my resources/logback.xml:

<configuration>
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%d [%thread] %level %logger - %m%n</Pattern>
    </layout>
  </appender>
  <root level="${loglevel:-INFO}">
    <appender-ref ref="CONSOLE"/>
  </root>
</configuration>

Jetty总是生成调试日志,如果未启用调试,则记录日志会忽略它们,或者它正在使用logger.isDebugEnabled()设置其调试模式.有人对如何使它起作用有任何想法吗?

Jetty is either always generating debug logs, which are then ignored by the logger if debug is not enabled, or else it's using logger.isDebugEnabled() to set it's debug mode. Does anyone have any ideas on how to get this working?

推荐答案

将slf4j的jar放在{jetty}/lib/ext.中后,我遇到了同样的问题.
我通过将logback.xml文件放在{jetty}/resources

I had the same issue after placing slf4j's jar in {jetty}/lib/ext.
I solved it by placing this logback.xml file in {jetty}/resources

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level - %msg%n</pattern>
    </encoder>
  </appender>
  <root level="info">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

注意'level ="info"'.

说明:
在此配置中,Jetty用作记录器实现Slf4jLog.
Slf4jLog依次委托给Logback的实现.
logback.xml告诉您注销日志级别并使用STDOUT.
从这里可以看到标准的Jetty行为,除了可以通过logback.xml
配置日志记录级别. 与默认配置一样,如果需要,可以使用jetty-logging.xml.
当然,您可以绕过Jetty的PrintStream并使用Logback的Appenders.
如果您使用jetty-logging.xml,请参见以下流程:

Note the 'level="info"'.

Explanation:
In this configuration Jetty uses as Logger implementation Slf4jLog.
Slf4jLog, in turn, delegates to Logback's implementation.
The logback.xml tells to logback the log level and to use STDOUT.
From here the standard Jetty behavior is present, except you can configure logging levels via logback.xml
As in the default configuration, you can use jetty-logging.xml if you want.
Off course, you can bypass Jetty's PrintStreams and use Logback's Appenders.
Here the flow in case you use jetty-logging.xml:

SomeClass --> Slf4JLog --> ConsoleAppender--> STDOUT --> RolloverFileOutputStream
 (Jetty)      (Jetty)         (Logback)        (OS)           (Jetty)


修订:
码头7.2.2
slf4j 1.6.1
重新登录0.9.26


Revisions:
Jetty 7.2.2
slf4j 1.6.1
Logback 0.9.26

这篇关于Jetty 6总是生成调试日志吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆