Skip to content

Commit abf9d66

Browse files
committed
Document how to configure access logging
Also, the section on `server.*` configuration was poor so this commit also improves it. Closes gh-4989
1 parent fc2e51a commit abf9d66

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,35 @@ the two to configure programmatically. See the
507507
{github-code}/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors[`spring-boot-sample-tomcat-multi-connectors`]
508508
sample project for an example.
509509

510+
[[howto-configure-accesslogs]]
511+
=== Configure Access Logging
512+
Access logs can be configured for Tomcat and Undertow via their respective namespaces.
513+
514+
For instance, the following logs access on Tomcat with a
515+
https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Logging[custom pattern].
516+
517+
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
518+
----
519+
server.tomcat.basedir=my-tomcat
520+
server.tomcat.accesslog.enabled=true
521+
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms)
522+
----
523+
524+
NOTE: The default location for logs is a `logs` directory relative to the tomcat base dir
525+
and said directory is a temp directory by default so you may want to fix Tomcat's base
526+
directory or use an absolute path for the logs. In the example above, the logs will
527+
be available in `my-tomcat/logs` relative to the working directory of the application.
528+
529+
Access logging for undertow can be configured in a similar fashion
530+
531+
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
532+
----
533+
server.undertow.accesslog.enabled=true
534+
server.undertow.accesslog.pattern=%t %a "%r" %s (%D ms)
535+
----
536+
537+
Logs are stored in a `logs` directory relative to the working directory of the
538+
application. This can be customized via `server.undertow.accesslog.directory`.
510539

511540

512541
[[howto-use-behind-a-proxy-server]]

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,11 +1877,22 @@ file.
18771877

18781878
Common server settings include:
18791879

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

18871898

0 commit comments

Comments
 (0)