Document how to configure access logging

Also, the section on `server.*` configuration was poor so this commit
also improves it.

Closes gh-4989
This commit is contained in:
Stephane Nicoll 2016-02-11 16:59:47 +01:00
parent fc2e51a773
commit abf9d66edf
2 changed files with 44 additions and 4 deletions

View File

@ -507,6 +507,35 @@ the two to configure programmatically. See the
{github-code}/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors[`spring-boot-sample-tomcat-multi-connectors`]
sample project for an example.
[[howto-configure-accesslogs]]
=== Configure Access Logging
Access logs can be configured for Tomcat and Undertow via their respective namespaces.
For instance, the following logs access on Tomcat with a
https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Logging[custom pattern].
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----
server.tomcat.basedir=my-tomcat
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms)
----
NOTE: The default location for logs is a `logs` directory relative to the tomcat base dir
and said directory is a temp directory by default so you may want to fix Tomcat's base
directory or use an absolute path for the logs. In the example above, the logs will
be available in `my-tomcat/logs` relative to the working directory of the application.
Access logging for undertow can be configured in a similar fashion
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----
server.undertow.accesslog.enabled=true
server.undertow.accesslog.pattern=%t %a "%r" %s (%D ms)
----
Logs are stored in a `logs` directory relative to the working directory of the
application. This can be customized via `server.undertow.accesslog.directory`.
[[howto-use-behind-a-proxy-server]]

View File

@ -1877,11 +1877,22 @@ file.
Common server settings include:
* `server.port` -- The listen port for incoming HTTP requests.
* `server.address` -- The interface address to bind to.
* `server.session.timeout` -- A session timeout.
* Network settings: listen port for incoming HTTP requests (`server.port`), interface
address to bind to `server.address`, etc.
* Session settings: whether the session is persistent (`server.session.persistence`),
session timeout (`server.session.timeout`), location of session data
(`server.session.store-dir`) and session-cookie configuration (`server.session.cookie.*`).
* Error management: location of the error page (`server.error.path`), etc.
* <<howto.adoc#howto-configure-ssl,SSL>>
* <<howto.adoc#how-to-enable-http-response-compression,HTTP compression>>
See the {sc-spring-boot-autoconfigure}/web/ServerProperties.{sc-ext}[`ServerProperties`]
Spring Boot tries as much as possible to expose common settings but this is not always
possible. For those cases, dedicated namespaces offer server-specific customizations (see
`server.tomcat` and `server.undertow`). For instance,
<<howto.adoc#howto-configure-accesslogs,access logs>> can be configured with specific
features of the embedded servlet container.
TIP: See the {sc-spring-boot-autoconfigure}/web/ServerProperties.{sc-ext}[`ServerProperties`]
class for a complete list.