blob: a80a3ff103ba2514d7bb6a858e64e1d6e22da390 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter&nbsp;11.&nbsp;Jetty Logging</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty"><link rel="up" href="jetty-admin-guide.html" title="Part&nbsp;III.&nbsp;Jetty Administration Guide"><link rel="prev" href="sessions-usecases.html" title="Session Use Cases"><link rel="next" href="default-logging-with-stderrlog.html" title="Default Logging with Jetty&#8217;s StdErrLog"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script>
hljs.initHighlightingOnLoad();
</script><link type="text/css" rel="stylesheet" href="css/font-awesome/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small">
Version: 9.4.28-SNAPSHOT</span></td><td style="width: 50%"></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;11.&nbsp;Jetty Logging</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sessions-usecases.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;III.&nbsp;Jetty Administration Guide<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="default-logging-with-stderrlog.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at
<span class="website">www.webtide.com</span></a></h5><p>
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ...
scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development
</p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="configuring-logging"></a>Chapter&nbsp;11.&nbsp;Jetty Logging</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="configuring-logging.html#configuring-jetty-logging">Configuring Jetty Logging</a></span></dt><dt><span class="section"><a href="default-logging-with-stderrlog.html">Default Logging with Jetty&#8217;s StdErrLog</a></span></dt><dt><span class="section"><a href="configuring-jetty-request-logs.html">Configuring Jetty Request Logs</a></span></dt><dt><span class="section"><a href="configuring-logging-modules.html">Jetty Logging Integrations (SLF4J, Log4j, Logback, JCL, JUL)</a></span></dt><dt><span class="section"><a href="example-logging-logback-centralized.html">Centralized Logging using Logback</a></span></dt><dt><span class="section"><a href="jetty-dump-tool.html">Jetty Dump Tool</a></span></dt></dl></div><p>This chapter discusses various options for configuring logging.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="configuring-jetty-logging"></a>Configuring Jetty Logging</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="configuring-logging.html#selecting-log-framework">Selecting the Log Framework</a></span></dt><dt><span class="section"><a href="configuring-logging.html#configuring-jetty-stderrlog">The jetty-logging.properties file</a></span></dt></dl></div><p>Jetty provides logging via its own <code class="literal">org.eclipse.jetty.util.log.Logger</code> layer, and does not natively use any existing Java logging framework.
All logging events, produced via the Jetty logging layer, have a name, a level, and a message.
The name is a FQCN (fully qualified class name) similar to how all existing Java logging frameworks operate.</p><p>Jetty logging, however, has a slightly different set of levels that it uses internally:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">WARN</span></dt><dd>For events serious enough to inform and log, but not fatal.</dd><dt><span class="term">INFO</span></dt><dd>Informational events.</dd><dt><span class="term">DEBUG</span></dt><dd>Debugging events (very noisy).</dd><dt><span class="term">IGNORE</span></dt><dd>Exception events that you can safely ignore, but useful for some people.
You might see this level as DEBUG under some Java logging framework configurations, where it retains the <span class="emphasis"><em>ignore</em></span> phrase somewhere in the logging.</dd></dl></div><div class="blockquote"><blockquote class="blockquote"><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="fa fa-asterisk" aria-hidden="true"></i> Note</h3><p>Jetty logging produces no FATAL or SEVERE events.</p></div></blockquote></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="selecting-log-framework"></a>Selecting the Log Framework</h3></div></div></div><p>Configure the Jetty logging layer via the <code class="literal">org.eclipse.jetty.util.log.Log</code> class, following <a class="link" href="https://github.com/eclipse/jetty.project/tree/jetty-9.4.x/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java" target="_top">these rules</a>.</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">Load Properties</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">First from a Classpath Resource called <code class="literal">jetty-logging.properties</code> (if found).</li><li class="listitem">Then from the <code class="literal">System.getProperties()</code>.</li></ul></div></li><li class="listitem"><p class="simpara">Determine the log implementation.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">If property <code class="literal">org.eclipse.jetty.util.log.class</code> is defined, load the class it defines as the logger implementation from the server <code class="literal">classpath</code>.</li><li class="listitem">If the class <code class="literal">org.slf4j.Logger</code> exists in server classpath, the Jetty implementation becomes <code class="literal">org.eclipse.jetty.util.log.Slf4jLog</code>.</li><li class="listitem">If no logger implementation is specified, default to <code class="literal">org.eclipse.jetty.util.log.StdErrLog</code>.</li></ul></div></li></ol></div><div class="blockquote"><blockquote class="blockquote"><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><i class="fa fa-asterisk" aria-hidden="true"></i> Note</h3><p>You can create your own custom logging by providing an implementation of the <a class="link" href="http://www.eclipse.org/jetty/javadoc/9.4.28-SNAPSHOTorg/eclipse/jetty/util/log/Logger.html" target="_top">Jetty Logger API</a>.
For an example of a custom logger, see <a class="link" href="https://github.com/eclipse/jetty.project/tree/jetty-9.4.x/jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java" target="_top">JavaUtilLog.java</a>.</p></div></blockquote></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="configuring-jetty-stderrlog"></a>The jetty-logging.properties file</h3></div></div></div><p>By default, the internal Jetty Logging discovery mechanism will load logging specific properties from a classpath resource called <code class="literal">jetty-logging.properties</code> and then initialize the Logging from a combination of properties found in that file, along with any System Properties.
A typical jetty-logging.properties file will include at least the declaration of which logging implementation you want to use by defining a value for the <code class="literal">org.eclipse.jetty.util.log.class</code> property.</p><p>Examples for various logging frameworks can be found later in this documentation.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Default Logging with <a class="link" href="default-logging-with-stderrlog.html" title="Default Logging with Jetty&#8217;s StdErrLog">Jetty&#8217;s StdErrLog</a></li><li class="listitem">Using <a class="link" href="configuring-logging-modules.html#example-logging-log4j" title="Logging with Log4j and Log4j2">Log4j or Log4j2 via SLF4J</a></li><li class="listitem">Using <a class="link" href="configuring-logging-modules.html#example-logging-logback" title="Logging with Logback">Logback via SLF4J</a></li><li class="listitem">Using <a class="link" href="configuring-logging-modules.html#example-logging-java-util-logging" title="Java Util Logging with SLF4J">Java Util Logging via SLF4J</a></li><li class="listitem">Using Java Commons Logging via SLF4J</li><li class="listitem"><a class="link" href="example-logging-logback-centralized.html" title="Centralized Logging using Logback">Centralized Logging with Logback and Sfl4jLog</a></li></ul></div></div></div></div><script type="text/javascript">
SyntaxHighlighter.all()
</script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sessions-usecases.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="jetty-admin-guide.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="default-logging-with-stderrlog.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Session Use Cases&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;Default Logging with Jetty&#8217;s StdErrLog</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout">
See an error or something missing?
<span class="callout"><a href="http://github.com/eclipse/jetty.project">Contribute to this documentation at
<span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2020-03-10)</i></span></div></p></body></html>