我怎么能关掉码头的调试呢?

时间:2017-06-01 13:54:50

标签: java web-services web intellij-idea jetty

我有一个运行jetty的java应用程序:

public class ServerRunner {

    private final static org.apache.log4j.Logger logger = LoggingUtils.getLogger();

    public static void main(String[] args) throws Exception {
        PromptoConfig.s.initLog();


        final int port = 8082;

        final Server jettyServer = new Server(port);
        final HandlerCollection handlers = new HandlerCollection();

        // Creating the first web application context
        final WebAppContext webappContext = new WebAppContext();

        System.out.println("===== PromptoConfig.s.RESOURCES_BASE " + PromptoConfig.s.RESOURCES_BASE);
        webappContext.setResourceBase(PromptoConfig.s.RESOURCES_BASE);
        webappContext.setContextPath("/");

        System.out.println("===== PromptoConfig.s.WEB_XML_PATH " + PromptoConfig.s.WEB_XML_PATH);
        webappContext.setDefaultsDescriptor(PromptoConfig.s.WEB_XML_PATH);
//        webappContext.setTempDirectory(new File(temp));


        DBSQLConfig.s().DB = com.waze.prompto.config.DBSQLConfig.s.DB;


        webappContext.setExtractWAR(false);
        handlers.addHandler(webappContext);

        // Adding the handlers to the server.
        jettyServer.setHandler(handlers);

        try {
            jettyServer.start();
            jettyServer.join();
        } catch (Exception ex) {
            logger.error("failed to init jetty server", ex);
        } finally {
            jettyServer.destroy();
        }
    }
}

我在intellij控制台的日志调试信息中看到了:

633016 [org.eclipse.jetty.server.session.HashSessionManager@22fcf7abTimer] DEBUG org.eclipse.jetty.server.session  - Scavenging sessions at 1496325042425

如何关闭此调试日志?

2 个答案:

答案 0 :(得分:2)

您似乎已在您的环境中配置了log4j。

StdErrLog

输出格式也不是Jetty内部633016 [org.eclipse.jetty.server.session.HashSessionManager@22fcf7abTimer] DEBUG org.eclipse.jetty.server.session - Scavenging sessions at 1496325042425 的默认格式

此致

2017-06-01 14:30:17.978:DBUG:oejs.session:main: SessionManager default maxInactiveInterval=1800

Jetty的StdErrLog

org.eclipse.jetty

此时,这不再是一个jetty日志配置,而是一个log4j配置。

只需在log4j.propertieslog4j.xml

中将{ "responseHeader": { "params": { "q": "*:*", "facet.heatmap": "location_p", "facet.heatmap.geom": "[\"0.6247379779815674 51.52351760864258\" TO \"5.051644802093506 51.570556640625\"]", "facet.heatmap.distErrPct": "0.28", "facet": "true", "wt": "json" } }, "response": { "numFound": 5876, "start": 0, "docs": [ // docs... ] }, "facet_counts": { "facet_queries": {}, "facet_fields": {}, "facet_ranges": {}, "facet_intervals": {}, "facet_heatmaps": { "location_p": [ "gridLevel", 4, "columns", 14, "rows", 1, "minX", 0.3515625, "maxX", 5.2734375, "minY", 51.50390625, "maxY", 51.6796875, "counts_ints2D", [ // heatmap... ] ] } } } 记录器级别设置为INFO或WARN

答案 1 :(得分:0)

如果您使用 eclipse 中的 jetty-server

添加配置

log4j.category.org.eclipse.jetty=error

在文件 src/main/resources/log4j.properties 中