Jetty: how to disable logging?

前端 未结 7 1880
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 02:35

I am trying to embed Jetty 6.1 in another program. Jetty is dumping INFO-log information and I need to turn it off. Is there a simple way to disable logging programmaticaly?

7条回答
  •  礼貌的吻别
    2020-12-30 02:55

    Looking at the debugging page mentioned by Vinay:

    Jetty uses the SLF4J logging infrastructure to bridge to commons-logging for JSP2.0. This means that commons-log messages are sent to the SLF4J interface.

    We ship the Simple log implementation, which will only output INFO level and above messages to stderr.

    However, you can replace the Simple log with any other SLF4J log implementation by removing the lib/jsp-2.0/slf4j-simple-1.0-rc5.jar and copying in the SLF4J impl of your choice. The core Jetty code has a soft dependency on SLF4J, meaning that if an SLF4J impl is found on the classpath at startup Jetty will direct all logging messages to it.

    Alternatively, you can remove the SLF4J jars altogether and use commons-logging instead by copying in the commons-logging jar and a commons-logging compliant log impl, such as log4j, to the lib/ directory. However, if you do that, be aware that as the core Jetty code does not use commons-logging, it will log messages to stderr instead. Read on to learn how to get the stderr log mechanism to print DEBUG level messages.

    So it's a matter of putting the right jar file. For instance, you could put a log4j compatible interface and configuring your log4j configuration file properly to mute completely jetty's logging statements or to be more verbose.

提交回复
热议问题