Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Jetty/Feature/Jetty Logging



Selecting the Log Framework

If Jetty does not discover an slf4j jar on the classpath, then it will use the internal org.eclipse.jetty.util.log.StdErrLog logger. If an slf4j jar is on the classpath, then slf4j configuration mechanisms are used to select the actual logger used (eg logback, java.util.logging, or log4j,can all be used via slf4j).


For an example of a custom Logger, see http://download.eclipse.org/jetty/stable-7/xref/org/eclipse/jetty/util/log/JavaUtilLog.html

Default Jetty Logging–org.eclipse.jetty.util.log.StdErrLog

The default Jetty log has one name for all logs, using a system property that turns on DEBUG and reports on predefined events that write to STDERR. You configure logging at startup.

Jetty logging includes some system properties that you can use to control filtering. For example, org.eclipse.jetty.util.log.stderr.DEBUG sets the level filter to DEBUG and higher, with the possible levels being IGNORE, DEBUG, INFO, and WARN. By default, Jetty filters from INFO and above, showing only INFO and WARN logs.

  • With StdErrLog you always see INFO and WARN logs. You can add DEBUG and/or IGNORE logs.
  • With the exception of org.eclipse.jetty.util.log.class these system properties take boolean values (true or false).

You set these system properties when you start Jetty.

The following system properties define Jetty Logging:

System Property Project
org.eclipse.jetty.util.log.class Sets the implementation class for Jetty Logging. Allows you to use an external logging framework with Jetty.
org.eclipse.jetty.util.log.IGNORED Shows the IGNORED logging events (ones not deemed pertinent.
org.eclipse.jetty.util.log.DEBUG (deprecated) Shows DEBUG events and up.
org.eclipse.jetty.util.log.stderr.DEBUG Shows DEBUG events and up (for StdErrLog)
org.eclipse.jetty.util.log.SOURCE (deprecated) Shows the output of the log.
org.eclipse.jetty.util.log.stderr.SOURCE Includes the source filename and line number in the StdErrLog output
org.eclipse.jetty.util.log.stderr.LONG Uses the long form FQCN in the StdErrLog output (defaults to false).

Changing log level in etc/jetty.xml

<Get class="org.eclipse.jetty.util.log.Log" name="log">
    <Call name="setDebugEnabled">
        <Arg type="boolean">true</Arg>
    </Call>
</Get>

Using etc/jetty-logging.xml

You can use etc/jetty-logging.xml to take all System.out and System.err output (from any source) and route it to a rolling log file. To do so, include etc/jetty-logging.xml on Jetty startup.

java -jar start.jar etc/jetty-logging.xml

Using Access Logging

Access logging, also called request logging, refers to a well-established NCSA log file format for all requests that the server processes. This log file format is standardized so that other tooling can use the information for other reasons.

To enable access logging with Jetty, include the etc/jetty-requestlog.xml on Jetty startup.

Back to the top