以编程方式配置Jetty的记录器 [英] Programmatically configure Jetty's logger

查看:106
本文介绍了以编程方式配置Jetty的记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式配置Jetty的记录器?我在一个独立的应用程序中使用Jetty,并且想要更改一些Jetty内部生成的警告的日志级别.理想情况下,我可以以编程方式(即在代码中)执行此操作,而不必指定XML文件.

How do I programmatically configure Jetty's logger? I'm using Jetty in a standalone application and want to change the log level of some of Jetty's internally generated warnings. Ideally I could do this programmatically (ie, in code) without having to specify an XML file.

我正在使用Jetty 6.1.20.

I'm using Jetty 6.1.20.

推荐答案

Jetty使用 slf4j ,因此您可以使用所需的任何日志记录框架或slf4j实现.

Jetty uses slf4j, so you can use any logging framework or slf4j implementation you want .

Jetty附带了Simple slf4j实现,该实现记录INFO级别或更高级别.因此,您可以将捆绑的slf4j jar更改为具有所需日志级别的实现,或者将桥接器连接至具有所需级别的另一个框架,或者提供可通过(例如)

Jetty comes with the Simple slf4j implementation, which logs INFO levels or above. So, you either change the bundled slf4j jars to an implementation with the log levels you want, or use a bridge to another framework with the levels you want, or provide a custom log class you can set via, for example,

System.setProperty("org.mortbay.log.class", "com.example.JettyLog");

更多信息此处.

这篇关于以编程方式配置Jetty的记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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