blob: 79049f2cf55525793feb438f7e3fae8b168b5848 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Default Logging with Jetty&#8217;s StdErrLog</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="configuring-logging.html" title="Chapter&nbsp;11.&nbsp;Jetty Logging"><link rel="prev" href="configuring-logging.html" title="Chapter&nbsp;11.&nbsp;Jetty Logging"><link rel="next" href="configuring-jetty-request-logs.html" title="Configuring Jetty Request Logs"><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">Default Logging with Jetty&#8217;s StdErrLog</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuring-logging.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;11.&nbsp;Jetty Logging<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="configuring-jetty-request-logs.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="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="default-logging-with-stderrlog"></a>Default Logging with Jetty&#8217;s StdErrLog</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="default-logging-with-stderrlog.html#stderrlog-configuration">StdErrLog Configuration</a></span></dt><dt><span class="section"><a href="default-logging-with-stderrlog.html#deprecated-parameters">Deprecated Parameters</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="stderrlog-configuration"></a>StdErrLog Configuration</h3></div></div></div><p>If you do nothing to configure a separate logging framework, Jetty will default to using an internal <code class="literal">org.eclipse.jetty.util.log.StdErrLog</code> implementation.
This will output all logging events to STDERR (aka <code class="literal">System.err</code>).</p><p>Simply use Jetty and <code class="literal">StdErrLog</code>-based logging is output to the console.</p><p>Included in the Jetty distribution is a logging module named <code class="literal">console-capture</code> that is capable of performing simple capturing of all STDOUT (<code class="literal">System.out</code>) and STDERR (<code class="literal">System.err</code>) output to a file that is rotated daily.</p><p>To enable this feature, simply activate the <code class="literal">console-capture</code> module on the command line:</p><div class="screenexample"><pre class="screen">[my-base]$ java -jar ../start.jar --add-to-start=console-capture
INFO : console-capture initialized in ${jetty.base}/start.d/console-capture.ini
MKDIR : ${jetty.base}/logs
INFO : Base directory was modified
[my-base]$ tree
.
&#9500;&#9472;&#9472; logs
&#9492;&#9472;&#9472; start.d
&#9492;&#9472;&#9472; console-capture.ini</pre></div><p>The default configuration for logging output will create a file <code class="literal">${jetty.base}/logs/yyyy_mm_dd.stderrout.log</code> which allows configuration of the output directory by setting the <code class="literal">jetty.logs</code> property.</p><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>By default, logs are not set to be appended, meaning a the log file is wiped clean upon sever restart.
You can change this setting by editing the <code class="literal">console-capture.ini</code> and un-commenting the line that reads <code class="literal">jetty.console-capture.append=true</code>.</p></div></blockquote></div><p>Just enabling the <code class="literal">console-capture</code> will simply output the values of STDERR and STDOUT to a log file.
To customize the log further, a module named <code class="literal">logging-jetty</code> is available to provides a default properties file to configure.
As with <code class="literal">console-capture</code>, you activate the <code class="literal">logging-jetty</code> on the command line.</p><div class="screenexample"><pre class="screen">[my-base]$ java -jar ../start.jar --add-to-start=logging-jetty
INFO : logging-jetty initialized in ${jetty.base}/start.d/logging-jetty.ini
INFO : resources transitively enabled
MKDIR : ${jetty.base}/resources
COPY : ${jetty.home}/modules/logging-jetty/resources/jetty-logging.properties to ${jetty.base}/resources/jetty-logging.properties
INFO : Base directory was modified
[my-base]$ tree
.
&#9500;&#9472;&#9472; logs
&#9500;&#9472;&#9472; resources
&#9474;&nbsp;&nbsp; &#9492;&#9472;&#9472; jetty-logging.properties
&#9492;&#9472;&#9472; start.d
&#9500;&#9472;&#9472; console-capture.ini
&#9492;&#9472;&#9472; logging-jetty.ini</pre></div><p>Once activated, you can find the properties file at <code class="literal">${jetty.base}/resources/jetty-logging.properties</code>.
By default, the following parameters are defined.
To change them, un-comment the line and substitute your naming scheme and configuration choices.</p><pre 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"><code>## Force jetty logging implementation
#org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
## Set logging levels from: ALL, DEBUG, INFO, WARN, OFF
#org.eclipse.jetty.LEVEL=INFO
#com.example.LEVEL=INFO
## Hide stacks traces in logs?
#com.example.STACKS=false
## Show the source file of a log location?
#com.example.SOURCE=false</code></pre><p>There are a number of properties that can be defined in the configuration that will affect the behavior of StdErr logging with <code class="literal">console-capture</code>.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">&lt;name&gt;.LEVEL=&lt;level&gt;</code></span></dt><dd>Sets the logging level for all loggers within the <code class="literal">name</code> specified to the level, which can be (in increasing order of restriction) <code class="literal">ALL</code>, <code class="literal">DEBUG</code>, <code class="literal">INFO</code>, <code class="literal">WARN</code>, <code class="literal">OFF</code>.
The name (or hierarchy) can be a specific fully qualified class or a package namespace.
For example, <code class="literal">org.eclipse.jetty.http.LEVEL=DEBUG</code> is a package namespace approach to turn all loggers in the Jetty HTTP package to DEBUG level, and <code class="literal">org.eclipse.jetty.io.ChanelEndPoint.LEVEL=ALL</code> turns on all logging events for the specific class, including <code class="literal">DEBUG</code>, <code class="literal">INFO</code>, <code class="literal">WARN</code> (and even special internally ignored exception classes).
If more than one system property specifies a logging level, the most specific one applies.</dd><dt><span class="term"><code class="literal">&lt;name&gt;.SOURCE=&lt;boolean&gt;</code></span></dt><dd>Named Logger specific, attempts to print the Java source file name and line number from where the logging event originated.
Name must be a fully qualified class name (this configurable does not support package name hierarchy).
Default is false.
Be aware that this is a slow operation and has an impact on performance.</dd><dt><span class="term"><code class="literal">&lt;name&gt;.STACKS=&lt;boolean&gt;</code></span></dt><dd>Named Logger specific, controls the display of stacktraces.
Name must be a fully qualified class name (this configurable does not support package name hierarchy).
Default is true.</dd><dt><span class="term"><code class="literal">org.eclipse.jetty.util.log.stderr.SOURCE=&lt;boolean&gt;</code></span></dt><dd>Special Global Configuration.
Attempts to print the Java source file name and line number from where the logging event originated.
Default is false.</dd><dt><span class="term"><code class="literal">org.eclipse.jetty.util.log.stderr.LONG=&lt;boolean&gt;</code></span></dt><dd><p class="simpara">Special Global Configuration.
When true, outputs logging events to <code class="literal">STDERR</code> using long form, fully qualified class names.
When false, uses abbreviated package names.
Default is false.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Example when set to false:</li></ul></div><div class="screenexample"><pre class="screen">2016-10-21 15:31:01.248:INFO::main: Logging initialized @332ms to org.eclipse.jetty.util.log.StdErrLog
2016-10-21 15:31:01.370:INFO:oejs.Server:main: jetty-9.4.0-SNAPSHOT
2016-10-21 15:31:01.400:INFO:oejs.AbstractConnector:main: Started ServerConnector@2c330fbc{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2016-10-21 15:31:01.400:INFO:oejs.Server:main: Started @485ms</pre></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Example when set to true:</li></ul></div><div class="screenexample"><pre class="screen">2016-10-21 15:31:35.020:INFO::main: Logging initialized @340ms to org.eclipse.jetty.util.log.StdErrLog
2016-10-21 15:31:35.144:INFO:org.eclipse.jetty.server.Server:main: jetty-9.4.0-SNAPSHOT
2016-10-21 15:31:35.174:INFO:org.eclipse.jetty.server.AbstractConnector:main: Started ServerConnector@edf4efb{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2016-10-21 15:31:35.175:INFO:org.eclipse.jetty.server.Server:main: Started @495ms</pre></div></dd></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="deprecated-parameters"></a>Deprecated Parameters</h3></div></div></div><p>These parameters existed in prior versions of Jetty, and are no longer supported.
They are included here for historical (and search engine) reasons.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">org.eclipse.jetty.util.log.DEBUG</code></span></dt><dd><p class="simpara">Formerly used to enable DEBUG level logging on any logger used within Jetty (not just Jetty&#8217;s own logger).</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Replaced with using the logger implementation specific configuration and level filtering.</li></ul></div></dd><dt><span class="term"><code class="literal">org.eclipse.jetty.util.log.stderr.DEBUG</code></span></dt><dd><p class="simpara">Formerly used to enable DEBUG level logging on the internal Jetty <code class="literal">StdErrLog</code> implementation.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Replaced with level specific equivalent.
Example: <code class="literal">org.eclipse.jetty.LEVEL=DEBUG</code></li></ul></div></dd><dt><span class="term"><code class="literal">DEBUG</code></span></dt><dd><p class="simpara">Ancient debugging flag that turned on all debugging, even non-logging debugging.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Jetty no longer uses because many third party libraries employ this overly simple property name, which would generate far too much console output.</li></ul></div></dd></dl></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="configuring-logging.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="configuring-logging.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="configuring-jetty-request-logs.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;11.&nbsp;Jetty Logging&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;Configuring Jetty Request Logs</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>