0

I have a java app that runs jetty:

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();
        }
    }
}

i see in the logs debug info in intellij console:

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

How can i turn this debug logs off?

Elad Benda2
  • 13,852
  • 29
  • 82
  • 157
  • 1
    Possible duplicate of [Jetty: how to disable logging?](https://stackoverflow.com/questions/2120370/jetty-how-to-disable-logging) – Kuba Jun 01 '17 at 14:09

2 Answers2

2

You appear to have configured log4j on your environment.

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

The output format is also not the default format from Jetty's internal StdErrLog

Yours

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

Jetty's StdErrLog

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

At this point, this is no longer a jetty logging configuration, but a log4j configuration.

Just set the org.eclipse.jetty logger level to INFO or WARN in your log4j.properties or log4j.xml

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • `Just set the org.eclipse.jetty logger level to INFO or WARN in your log4j.properties or log4j.xml` can you please explain how? – Elad Benda2 Jun 05 '17 at 06:41
  • That is specific to your environment, with log4j it can be done in many possible ways. Consult your log4j configuration files (wherever they may be). See other questions on stackoverflow for hints ... https://stackoverflow.com/questions/2763740/log4j-log-output-of-a-specific-class-to-a-specific-appender – Joakim Erdfelt Jun 06 '17 at 13:45
0

If you use jetty-server from eclipse

Add configuration

log4j.category.org.eclipse.jetty=error

in the file src/main/resources/log4j.properties

Ronald Coarite
  • 4,460
  • 27
  • 31