incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling Website > Client Request Logging
Date Fri, 05 Aug 2011 12:20:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Client+Request+Logging">Client
Request Logging</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~fmeschbe">Felix
Meschberger</a>
    </h4>
        <br/>
                         <h4>Changes (6)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>|| Parameter || Name ||
Default || Description || <br></td></tr>
            <tr><td class="diff-changed-lines" >| Request Log Name | {{request.log.output}}
| Name of the destination for the request log. The request log logs the entry and exit of
each request into and out of the system together with the entry time, exit time, time to process
the request, a request counter as well as the final status code and response content type.
In terms of Request Logger Service formats, request entry is logged with the format {{%t <span
class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">\</span>[%R]
<span class="diff-added-chars"style="background-color: #dfd;">\</span>-&gt;</span>
%m %U%q %H}} and request exit is logged with the format <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{{%{end}t
[%R] &lt;-</span> <span class="diff-added-words"style="background-color: #dfd;">{{%\{end}t
\[%R] &lt;\-</span> %s <span class="diff-changed-words">%<span class="diff-added-chars"style="background-color:
#dfd;">\</span>{Content-Type}o</span> %Dms}} (See [#Log Format Specification]
below for the specification of the format). | <br></td></tr>
            <tr><td class="diff-unchanged" >| Request Log Type | {{request.log.outputtype}}
| Type of Logger named with the Logger Name parameter. See [#Log Output] below | <br>|
Enable Request Log | {{request.log.enabled}} | Whether to enable Request logging or not. |
<br></td></tr>
            <tr><td class="diff-changed-lines" >| Access Log Name | {{access.log.output}}
| Name of the destination for the access log. The access log writes an entry for each request
as the request terminates using the NCSA extended/combined log format. In terms of Request
Logger Service formats the access log is written with the format {{%h %l %u %t &quot;%r&quot;
%&gt;s %b <span class="diff-changed-words">&quot;%<span class="diff-added-chars"style="background-color:
#dfd;">\</span>{Referer}i&quot; &quot;%<span class="diff-added-chars"style="background-color:
#dfd;">\</span>{User-Agent}i&quot;}}</span> (See [#Log Format Specification]
below for the specification of the format). | <br></td></tr>
            <tr><td class="diff-unchanged" >| Access Log Type | {{access.log.outputtype}}
| Type of Logger named with the Logger Name parameter. See [#Log Output] below | <br></td></tr>
            <tr><td class="diff-unchanged" >| Enable Access Log | {{access.log.enabled}}
| Whether to enable Access logging or not. | <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >*Modifiers* <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Particular items can be restricted
to print only for responses with specific HTTP status codes by placing a comma-separated list
of status codes immediately following the &quot;%&quot;. For example, <span class="diff-changed-words">&quot;%400,501<span
class="diff-added-chars"style="background-color: #dfd;">\</span>{User-agent}i&quot;</span>
logs User-agent on 400 errors and 501 errors only. For other status codes, the literal string
&quot;-&quot; will be logged. The status code list may be preceded by a &quot;!&quot;
to indicate negation: <span class="diff-changed-words">&quot;%!200,304,302<span
class="diff-added-chars"style="background-color: #dfd;">\</span>{Referer}i&quot;</span>
logs Referer on all requests that do not return one of the three specified codes. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The Apache httpd modifiers
&quot;&lt;&quot; and &quot;&gt;&quot;  are not supported by Sling
and currently ignored. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h4. Rotating Logger Files <br>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">If
you want to write the request (and access) logging information into a rotated file, you should
configure as follows: <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">TBD</span>
<span class="diff-added-words"style="background-color: #dfd;"> </span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
# Configure the Log Type to be a _Logger Name_ and some usefull Logger name. For example {{clientlog.request}}.
<br> # Create an _Apache Sling Logging Logger Configuration_ for this Logger name according
to [Logging Configuration|Logging#Logger Configuration] with the following setup: <br>
 ** Allow message at INFO (Information) level to be logged which is the level used by the
request loggers <br>  ** Define the appropriate log file name, for example {{logs/client.request.log}}
<br>  ** Use only {{\{5}}} as the message format because request logger messages are
generally already fully formated with required timestamp etc. <br>  ** Add any Logger
names used for the client request log configuration, {{clientlog.request}} in the example
above, to the Logger field. By clicking on the {{+}} (plus) button you may add more than a
single logger name whose messages are written to this file. <br> # Optionally, you may
create an _Apache Sling Logging Writer Configuration_ for the log file defined in the previous
step to better control rotation setup. See [Log Writer Configuration|Logging#Log Writer Configuration]
for full details. <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="ClientRequestLogging-ClientRequestLogging"></a>Client
Request Logging</h1>

<p>Sling provides extensive support to log various information at the before and after
processing client requests. Out of the box, there are two loggers configured to write traditional
<tt>access.log</tt> and <tt>request.log</tt> files. In addition more
logging can be configured by providing OSGi Configuration Admin configuration.</p>

<h2><a name="ClientRequestLogging-Traditionalaccess.logandrequest.logFiles"></a>Traditional
access.log and request.log Files</h2>

<p>In the Web Console configure the <em>Apache Sling Request Logger</em>
(PID=<tt>org.apache.sling.engine.impl.log.RequestLogger</tt>) configuration.</p>

<p>In the Sling Web Console locate the Configuration page (<tt>/system/console/configMgr</tt>)
and click on the <tt>+</tt> (plus) symbol on the <em>Apache Sling Customizable
Request Data Logger</em> line. This opens a dialog to enter the configuration whose
properties can be configured as follows:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter </th>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> Request Log Name </td>
<td class='confluenceTd'> <tt>request.log.output</tt> </td>
<td class='confluenceTd'> Name of the destination for the request log. The request log
logs the entry and exit of each request into and out of the system together with the entry
time, exit time, time to process the request, a request counter as well as the final status
code and response content type. In terms of Request Logger Service formats, request entry
is logged with the format <tt>%t [%R] &#45;&gt; %m %U%q %H</tt> and request
exit is logged with the format <tt>%{end}t [%R] &lt;&#45; %s %{Content-Type}o
%Dms</tt> (See <a href="#ClientRequestLogging-LogFormatSpecification">Log Format
Specification</a> below for the specification of the format). </td>
</tr>
<tr>
<td class='confluenceTd'> Request Log Type </td>
<td class='confluenceTd'> <tt>request.log.outputtype</tt> </td>
<td class='confluenceTd'> Type of Logger named with the Logger Name parameter. See <a
href="#ClientRequestLogging-LogOutput">Log Output</a> below </td>
</tr>
<tr>
<td class='confluenceTd'> Enable Request Log </td>
<td class='confluenceTd'> <tt>request.log.enabled</tt> </td>
<td class='confluenceTd'> Whether to enable Request logging or not. </td>
</tr>
<tr>
<td class='confluenceTd'> Access Log Name </td>
<td class='confluenceTd'> <tt>access.log.output</tt> </td>
<td class='confluenceTd'> Name of the destination for the access log. The access log
writes an entry for each request as the request terminates using the NCSA extended/combined
log format. In terms of Request Logger Service formats the access log is written with the
format <tt>%h %l %u %t "%r" %&gt;s %b "%{Referer}i" "%{User-Agent}i"</tt>
(See <a href="#ClientRequestLogging-LogFormatSpecification">Log Format Specification</a>
below for the specification of the format). </td>
</tr>
<tr>
<td class='confluenceTd'> Access Log Type </td>
<td class='confluenceTd'> <tt>access.log.outputtype</tt> </td>
<td class='confluenceTd'> Type of Logger named with the Logger Name parameter. See <a
href="#ClientRequestLogging-LogOutput">Log Output</a> below </td>
</tr>
<tr>
<td class='confluenceTd'> Enable Access Log </td>
<td class='confluenceTd'> <tt>access.log.enabled</tt> </td>
<td class='confluenceTd'> Whether to enable Access logging or not. </td>
</tr>
</tbody></table>
</div>



<h4><a name="ClientRequestLogging-LogOutput"></a>Log Output</h4>

<p>Output of client request logging is defined by the Logger Type and and Logger Name
where the use of the Logger Name property value depends on the Logger Type:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Type Code </th>
<th class='confluenceTh'> Type Name </th>
<th class='confluenceTh'> Description and Logger Name interpretation </th>
</tr>
<tr>
<td class='confluenceTd'> 0 </td>
<td class='confluenceTd'> Logger Name </td>
<td class='confluenceTd'> Writes the logging information to a named SLF4J Logger. The
name of the Logger is defined in the Logger Name property. The actual destination of the log
messages is defined the SLF4J configuration for the named logger </td>
</tr>
<tr>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> File Name </td>
<td class='confluenceTd'> Writes the logging information to a file, on message per line.
The file name is an absolute or relative path name. If the name is relative, it is resolved
against the <tt>sling.home</tt> framework property. </td>
</tr>
<tr>
<td class='confluenceTd'> 2 </td>
<td class='confluenceTd'> RequestLog Service </td>
<td class='confluenceTd'> Sends the logging information to a <tt>org.apache.sling.engine.RequestLog</tt>
service whose <tt>requestlog.name</tt> service registration property must the
same as the value of the Logger Name property. If more than one such service is registered,
all services are called. If no such service is registered, the logging information is discarded.
Using RequestLog Services is deprecated. </td>
</tr>
</tbody></table>
</div>


<p><b>Note:</b> If logging to a file, this file is not rotated and/or limited
by size. To get log file rotation use the <em>Logger Name</em> logging type. See
<a href="#ClientRequestLogging-RotatingLoggerFiles">Rotating Logger Files</a>
below for information on how logging information can be written to rotated and/or size limited
files.</p>


<h3><a name="ClientRequestLogging-AdditionalperrequestLoggers"></a>Additional
per-request Loggers</h3>

<p>In the Web Console create <em>Apache Sling Customizable Request Data Logger</em>
(Factory PID=<tt>org.apache.sling.engine.impl.log.RequestLoggerService</tt>) configuration.</p>

<p>In the Sling Web Console locate the Configuration page (<tt>/system/console/configMgr</tt>)
and click on the <tt>+</tt> (plus) symbol on the <em>Apache Sling Customizable
Request Data Logger</em> line. This opens a dialog to enter the configuration whose
properties can be configured as follows:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter </th>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> Log Format </td>
<td class='confluenceTd'> <tt>request.log.service.format</tt> </td>
<td class='confluenceTd'> Specify a <a href="#ClientRequestLogging-LogFormatSpecification">Log
Format Specification</a> as described below </td>
</tr>
<tr>
<td class='confluenceTd'> Logger Type </td>
<td class='confluenceTd'> <tt>request.log.service.outputtype</tt> </td>
<td class='confluenceTd'> Logger Name/<tt>0</tt> </td>
<td class='confluenceTd'> Type of Logger named with the Logger Name parameter. See <a
href="#ClientRequestLogging-LogOutput">Log Output</a> above </td>
</tr>
<tr>
<td class='confluenceTd'> Logger Name </td>
<td class='confluenceTd'> <tt>request.log.service.output</tt> </td>
<td class='confluenceTd'> <tt>request.log</tt> </td>
<td class='confluenceTd'> Name of the Logger to be used. See <a href="#ClientRequestLogging-LogOutput">Log
Output</a> above </td>
</tr>
<tr>
<td class='confluenceTd'> Request Entry </td>
<td class='confluenceTd'> <tt>request.log.service.onentry</tt> </td>
<td class='confluenceTd'> unchecked/<tt>false</tt> </td>
<td class='confluenceTd'> Whether logger is called at the start of request processing
or after processing the request </td>
</tr>
</tbody></table>
</div>




<h4><a name="ClientRequestLogging-LogFormatSpecification"></a>Log Format
Specification</h4>

<p>The log format specification follows the <a href="http://httpd.apache.org/docs/current/mod/mod_log_config.html"
class="external-link" rel="nofollow">definition of the <tt>format</tt> argument
for the <tt>LogFormat</tt> and <tt>CustomLog</tt> directives of Apache
httpd</a>:</p>

<p>The characteristics of the request itself are logged by placing "%" directives in
the format string, which are replaced in the log file by the values as follows:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Format String </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>%%</tt>  </td>
<td class='confluenceTd'> The percent sign </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%a</tt>  </td>
<td class='confluenceTd'> Remote IP-address </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%A</tt>  </td>
<td class='confluenceTd'> Local IP-address </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%B</tt>  </td>
<td class='confluenceTd'> Size of response in bytes, excluding HTTP headers. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%b</tt>  </td>
<td class='confluenceTd'> Size of response in bytes, excluding HTTP headers. In CLF
format, i.e. a '-' rather than a 0 when no bytes are sent. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{Foobar}C</tt>  </td>
<td class='confluenceTd'> The contents of cookie Foobar in the request sent to the server.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%D</tt>  </td>
<td class='confluenceTd'> The time taken to serve the request, in microseconds. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{FOOBAR}e</tt>  </td>
<td class='confluenceTd'>Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%f</tt>  </td>
<td class='confluenceTd'> The absolute path of the resolved resource </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%h</tt>  </td>
<td class='confluenceTd'> Remote host </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%H</tt>  </td>
<td class='confluenceTd'> The request protocol </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{Foobar}i</tt>  </td>
<td class='confluenceTd'> The contents of Foobar: header line(s) in the request sent
to the server. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%k</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%l</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%m</tt>  </td>
<td class='confluenceTd'> The request method </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{Foobar}n</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{Foobar}o</tt>  </td>
<td class='confluenceTd'> The contents of Foobar: header line(s) in the reply. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%p</tt>  </td>
<td class='confluenceTd'> The canonical port of the server serving the request </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{format}p</tt>  </td>
<td class='confluenceTd'> The canonical port of the server serving the request or the
server's actual port or the client's actual port. Valid formats are canonical, local, or remote.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%P</tt>  </td>
<td class='confluenceTd'> The <em>name of the thread</em> <del>process
ID of the child</del> that serviced the request. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{format}P</tt>  </td>
<td class='confluenceTd'> Same as <tt>%P</tt>; the <tt>format</tt>
parameter is ignored. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%q</tt>  </td>
<td class='confluenceTd'> The query string (prepended with a ? if a query string exists,
otherwise an empty string) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%r</tt>  </td>
<td class='confluenceTd'> First line of request </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%R</tt>  </td>
<td class='confluenceTd'> The number of requests processed by Sling since the last start.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%s</tt>  </td>
<td class='confluenceTd'> Status. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%t</tt>  </td>
<td class='confluenceTd'> Time the request was received (standard english format) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%{format}t</tt>  </td>
<td class='confluenceTd'> Same as <tt>%t</tt>; the <tt>format</tt>
parameter is ignored unless it is the literal value <em>end</em> indicating to
use the time of request terminating (instead of the time of request receipt). </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%T</tt>  </td>
<td class='confluenceTd'> The time taken to serve the request, in seconds. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%u</tt>  </td>
<td class='confluenceTd'> Remote user (from auth; may be bogus if return status (%s)
is 401) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%U</tt>  </td>
<td class='confluenceTd'> The URL path requested, not including any query string. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%v</tt>  </td>
<td class='confluenceTd'> The canonical ServerName of the server serving the request.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%V</tt>  </td>
<td class='confluenceTd'> Same as <tt>%v</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%X</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%I</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>%O</tt>  </td>
<td class='confluenceTd'> Not supported in Sling; prints nothing. </td>
</tr>
</tbody></table>
</div>



<p><b>Modifiers</b></p>

<p>Particular items can be restricted to print only for responses with specific HTTP
status codes by placing a comma-separated list of status codes immediately following the "%".
For example, "%400,501{User-agent}i" logs User-agent on 400 errors and 501 errors only. For
other status codes, the literal string "-" will be logged. The status code list may be preceded
by a "!" to indicate negation: "%!200,304,302{Referer}i" logs Referer on all requests that
do not return one of the three specified codes.</p>

<p>The Apache httpd modifiers "&lt;" and "&gt;"  are not supported by Sling
and currently ignored.</p>


<p><b>Some Notes</b></p>

<p>For security reasons non-printable and other special characters in %C, %i and %o
are escaped using \uhhhh sequences, where hhhh stands for the hexadecimal representation of
the character's unicode value. Exceptions from this rule are " and \, which are escaped by
prepending a backslash, and all whitespace characters, which are written in their Java-style
notation (\n, \t, etc).</p>


<h4><a name="ClientRequestLogging-RotatingLoggerFiles"></a>Rotating Logger
Files</h4>

<p>If you want to write the request (and access) logging information into a rotated
file, you should configure as follows:</p>

<ol>
	<li>Configure the Log Type to be a <em>Logger Name</em> and some usefull
Logger name. For example <tt>clientlog.request</tt>.</li>
	<li>Create an <em>Apache Sling Logging Logger Configuration</em> for this
Logger name according to <a href="/confluence/display/SLINGxSITE/Logging#Logging-LoggerConfiguration">Logging
Configuration</a> with the following setup:
	<ul>
		<li>Allow message at INFO (Information) level to be logged which is the level used
by the request loggers</li>
		<li>Define the appropriate log file name, for example <tt>logs/client.request.log</tt></li>
		<li>Use only {<tt>5</tt>} as the message format because request logger
messages are generally already fully formated with required timestamp etc.</li>
		<li>Add any Logger names used for the client request log configuration, <tt>clientlog.request</tt>
in the example above, to the Logger field. By clicking on the <tt>+</tt> (plus)
button you may add more than a single logger name whose messages are written to this file.</li>
	</ul>
	</li>
	<li>Optionally, you may create an <em>Apache Sling Logging Writer Configuration</em>
for the log file defined in the previous step to better control rotation setup. See <a
href="/confluence/display/SLINGxSITE/Logging#Logging-LogWriterConfiguration">Log Writer
Configuration</a> for full details.</li>
</ol>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Client+Request+Logging">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27823478&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Client+Request+Logging?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message