The Entry Log Valve helps the next
configuration attributes:
Attribute Description buffered
Flag to find out if logging will likely be buffered.
If set tofalse
, then entry logging will likely be written after every
request. Default worth:true
className
Java class identify of the implementation to make use of. This MUST be set to
org.apache.catalina.valves.AccessLogValve to make use of the
default entry log valve.situation
The identical as
conditionUnless
. This attribute is
supplied for backwards compatibility.conditionIf
Activates conditional logging. If set, requests will likely be
logged provided thatServletRequest.getAttribute()
is
not null. For instance, if this worth is ready to
vital
, then a specific request will solely be logged
ifServletRequest.getAttribute("important") != null
.
The usage of Filters is a straightforward option to set/unset the attribute
within the ServletRequest on many various requests.conditionUnless
Activates conditional logging. If set, requests will likely be
logged provided thatServletRequest.getAttribute()
is
null. For instance, if this worth is ready to
junk
, then a specific request will solely be logged
ifServletRequest.getAttribute("junk") == null
.
The usage of Filters is a straightforward option to set/unset the attribute
within the ServletRequest on many various requests.listing
Absolute or relative pathname of a listing through which log recordsdata
created by this valve will likely be positioned. If a relative path is
specified, it’s interpreted as relative to $CATALINA_BASE. If
no listing attribute is specified, the default worth is “logs”
(relative to $CATALINA_BASE).encoding
Character set used to put in writing the log file. An empty string means
to make use of the system default character set. Default worth: use the
system default character set.fileDateFormat
Permits a personalized timestamp within the entry log file identify.
The file is rotated every time the formatted timestamp modifications.
The default worth isyyyy-MM-dd
.
Should you want to rotate each hour, then set this worth
toyyyy-MM-dd.HH
.
The date format will all the time be localized
utilizing the localeen_US
.locale
The locale used to format timestamps within the entry log
traces. Any timestamps configured utilizing an
express SimpleDateFormat sample (%{xxx}t
)
are formatted on this locale. By default the
default locale of the Java course of is used. Switching the
locale after the AccessLogValve is initialized will not be supported.
Any timestamps utilizing the widespread log format
(CLF
) are all the time formatted within the locale
en_US
.maxDays
The utmost variety of days rotated entry logs will likely be retained for
earlier than being deleted. If not specified, the default worth of
-1
will likely be used which implies by no means delete outdated recordsdata.sample
A formatting structure figuring out the assorted info fields
from the request and response to be logged, or the phrase
widespread
ormixed
to pick out a
customary format. See beneath for extra info on configuring
this attribute.prefix
The prefix added to the beginning of every log file’s identify. If not
specified, the default worth is “access_log”.renameOnRotate
By default for a rotatable log the energetic entry log file identify
will include the present timestamp infileDateFormat
.
Throughout rotation the file is closed and a brand new file with the subsequent
timestamp within the identify is created and used. When setting
renameOnRotate
totrue
, the timestamp
is now not a part of the energetic log file identify. Solely throughout rotation
the file is closed after which renamed to incorporate the timestamp.
That is just like the habits of most log frameworks when
doing time based mostly rotation.
Default worth:false
requestAttributesEnabled
Set to
true
to examine for the existence of request
attributes (usually set by the RemoteIpValve and related) that ought to
be used to override the values returned by the request for distant
deal with, distant host, server port and protocol. If the attributes are
not set, or this attribute is ready tofalse
then the values
from the request will likely be used. If not set, the default worth of
false
will likely be used.resolveHosts
This attribute is now not supported. Use the connector
attributeenableLookups
as an alternative.You probably have
enableLookups
on the connector set to
true
and wish to ignore it, use %a as an alternative of
%h within the worth ofsample
.rotatable
Flag to find out if log rotation ought to happen.
If set tofalse
, then this file isn’t rotated and
fileDateFormat
is ignored.
Default worth:true
suffix
The suffix added to the tip of every log file’s identify. If not
specified, the default worth is ” (a zero-length string),
that means that no suffix will likely be added.Values for the
sample
attribute are made up of literal
textual content strings, mixed with sample identifiers prefixed by the “%”
character to trigger alternative by the corresponding variable worth from
the present request and response. The next sample codes are
supported:
- %a – Distant IP deal with
- %A – Native IP deal with
- %b – Bytes despatched, excluding HTTP headers, or ‘-‘ if zero
- %B – Bytes despatched, excluding HTTP headers
- %h – Distant host identify (or IP deal with if
enableLookups
for the connector is fake)- %H – Request protocol
- %l – Distant logical username from identd (all the time returns
‘-‘)- %m – Request methodology (GET, POST, and so on.)
- %p – Native port on which this request was acquired.
See additionally%{xxx}p
beneath.- %q – Question string (prepended with a ‘?’ if it exists)
- %r – First line of the request (methodology and request URI)
- %s – HTTP standing code of the response
- %S – Person session ID
- %t – Date and time, in Widespread Log Format
- %u – Distant person that was authenticated (if any), else ‘-‘
- %U – Requested URL path
- %v – Native server identify
- %D – Time taken to course of the request in millis. Be aware: In
httpd %D is microseconds. Behaviour will likely be aligned to httpd
in Tomcat 10 onwards.- %T – Time taken to course of the request, in seconds. Be aware: This
worth has millisecond decision whereas in httpd it has
second decision. Behaviour will likely be align to httpd
in Tomcat 10 onwards.- %F – Time taken to commit the response, in millis
- %I – Present request thread identify (can evaluate later with stacktraces)
There may be additionally assist to put in writing info incoming or outgoing
headers, cookies, session or request attributes and particular
timestamp codecs.
It’s modeled after the
Apache HTTP Server log configuration
syntax. Every of them can be utilized a number of instances with completely differentxxx
keys:
%{xxx}i
write worth of incoming header with identifyxxx
%{xxx}o
write worth of outgoing header with identifyxxx
%{xxx}c
write worth of cookie with identifyxxx
%{xxx}r
write worth of ServletRequest attribute with identifyxxx
%{xxx}s
write worth of HttpSession attribute with identifyxxx
%{xxx}p
write native (server) port (xxx==native
) or
distant (shopper) port (xxx=distant
)%{xxx}t
write timestamp on the finish of the request formatted utilizing the
enhanced SimpleDateFormat samplexxx
All codecs supported by SimpleDateFormat are allowed in
%{xxx}t
.
As well as the next extensions have been added:
sec
– variety of seconds for the reason that epochmsec
– variety of milliseconds for the reason that epochmsec_frac
– millisecond fractionThese codecs can’t be blended with SimpleDateFormat codecs in the identical format
token.Moreover one can outline whether or not to log the timestamp for the request begin
time or the response end time:
start
or prefixstart:
chooses
the request begin timefinish
or prefixfinish:
chooses
the response end timeBy including a number of
%{xxx}t
tokens to the sample, one can
additionally log each timestamps.The shorthand sample
sample="common"
corresponds to the Widespread Log Format outlined by
‘%h %l %u %t “%r” %s %b’.The shorthand sample
sample="combined"
appends the values of theReferer
andPerson-Agent
headers, every in double quotes, to thewidespread
sample.When Tomcat is working behind a reverse proxy, the shopper info
logged by the Entry Log Valve could symbolize the reverse proxy, the browser
or some mixture of the 2 relying on the configuration of Tomcat and
the reverse proxy. For Tomcat configuration choices see
Proxies Assist and the
Proxy How-To. For reverse proxies that
use mod_jk, see the generic
proxy documentation. For different reverse proxies, seek the advice of their
documentation.