@@ -814,6 +814,16 @@ in the order it is registered with WebServer routing.
814
814
This implies that if you register it last and another `Service` or
815
815
`Handler` finishes the request, the service will not be invoked.
816
816
817
+ To enable Access logging add the following dependency to project's `pom.xml`:
818
+
819
+ [source,xml]
820
+ ----
821
+ <dependency>
822
+ <groupId>io.helidon.webserver</groupId>
823
+ <artifactId>helidon-webserver-access-log</artifactId>
824
+ </dependency>
825
+ ----
826
+
817
827
818
828
=== Configuring Access Log in your code
819
829
@@ -843,121 +853,8 @@ server:
843
853
844
854
All options shown above are also available programmatically when using builder.
845
855
846
- === Configuration Options
847
-
848
- The following configuration options can be defined:
849
-
850
- [cols="2,2,2,5", role="flex, sm10"]
851
- |===
852
- |Config key |Default value |Builder method |Description
853
-
854
- |`enabled` |`true` |`enabled(boolean)` |When this option is set to `false`, access logging will be disabled
855
- |`logger-name` |`io.helidon.webserver.AccessLog` |`loggerName(String)` |Name of the logger to use when writing log entries
856
- |`format` |`helidon` |`helidonLogFormat()`, `commonLogFormat()`, `add(AccessLogEntry entry)` |Configuration of access log output,
857
- when `helidon` is defined, the Helidon log format (see below) is used.
858
- Can be configured to explicitly define log entries (see below as well)
859
- |`exclude-paths`|N/A|`excludePaths(List<String>)` | List of path patterns to exclude from access log. Path pattern syntax is as
860
- defined in `io.helidon.webserver.PathMatcher`. Can be used to exclude
861
- paths such as `/health` or `/metrics` to avoid cluttering log.
862
-
863
- |===
864
-
865
- === Supported Log Formats
866
-
867
- ==== Supported Log Entries
868
-
869
- The following log entries are supported in Helidon:
870
-
871
- [cols="2,2,5",role="flex, sm7"]
872
- |===
873
- |Config format |Class (to use with builder) |Description
874
-
875
- |%h |`HostLogEntry` |IP address of the remote host
876
- |%l |`UserIdLogEntry` |Client identity, always undefined in Helidon
877
- |%u |`UserLogEntry` |The username of logged-in user (when Security is used)
878
- |%t |`TimestampLogEntry` |The current timestamp
879
- |%r |`RequestLineLogEntry` |The request line (method, path and HTTP version)
880
- |%s |`StatusLogEntry` |The HTTP status returned to the client
881
- |%b |`SizeLogEntry` |The response entity size (if available)
882
- |%D |`TimeTakenLogEntry` |The time taken in microseconds
883
- |%T |`TimeTakenLogEntry` |The time taken in seconds
884
- |%{`header-name`}i |`HeaderLogEntry` |Value of a header (can have multiple such specification to write
885
- multiple headers)
886
- |===
887
-
888
- Currently we only support the entries defined above, with NO support for free text.
889
856
890
- ==== Helidon Log Format
891
- When format is set to `helidon`, the format used is:
892
-
893
- `"%h %u %t %r %s %b %D"`
894
-
895
- The entries logged:
896
-
897
- 1. IP Address
898
- 2. Username of a logged-in user
899
- 3. Timestamp
900
- 4. Request Line
901
- 5. HTTP Status code
902
- 6. Entity size
903
- 7. Time taken (microseconds)
904
-
905
- Access log example:
906
-
907
- [source, listing]
908
- ----
909
- 192.168.0.104 - [18/Jun/2019:22:28:55 +0200] "GET /greet/test HTTP/1.1" 200 53
910
- 0:0:0:0:0:0:0:1 - [18/Jun/2019:22:29:00 +0200] "GET /metrics/vendor HTTP/1.1" 200 1658
911
- 0:0:0:0:0:0:0:1 jack [18/Jun/2019:22:29:07 +0200] "PUT /greet/greeting HTTP/1.1" 200 21
912
- 0:0:0:0:0:0:0:1 jill [18/Jun/2019:22:29:12 +0200] "PUT /greet/greeting HTTP/1.1" 403 0
913
- 0:0:0:0:0:0:0:1 - [18/Jun/2019:22:29:17 +0200] "PUT /greet/greeting HTTP/1.1" 401 0
914
- ----
915
-
916
- ==== Common Log Format
917
- When format is set to `common`, the format used is:
918
-
919
- `"%h %l %u %t %r %s %b"`
920
-
921
- The entries logged:
922
-
923
- 1. IP Address
924
- 2. Client identity
925
- 3. Username of a logged-in user
926
- 4. Timestamp
927
- 5. Request Line
928
- 6. HTTP Status code
929
- 7. Entity size
930
-
931
- Access log example:
932
-
933
- [source, listing]
934
- ----
935
- 192.168.0.104 - - [18/Jun/2019:22:28:55 +0200] "GET /greet/test HTTP/1.1" 200 53
936
- 0:0:0:0:0:0:0:1 - - [18/Jun/2019:22:29:00 +0200] "GET /metrics/vendor HTTP/1.1" 200 1658
937
- 0:0:0:0:0:0:0:1 - jack [18/Jun/2019:22:29:07 +0200] "PUT /greet/greeting HTTP/1.1" 200 21
938
- 0:0:0:0:0:0:0:1 - jill [18/Jun/2019:22:29:12 +0200] "PUT /greet/greeting HTTP/1.1" 403 0
939
- 0:0:0:0:0:0:0:1 - - [18/Jun/2019:22:29:17 +0200] "PUT /greet/greeting HTTP/1.1" 401 0
940
- ----
941
-
942
- === Configuring Access Log with Java util logging
943
-
944
- To support a separate file for Access log entries, Helidon provides a custom
945
- log handler, that extends the `FileHandler`.
946
-
947
- To log to a file `access.log` with appending records after restart, you can use the
948
- following configuration in `logging.properties`:
949
-
950
- [source, properties]
951
- .Logging configuration file
952
- ----
953
- io.helidon.webserver.accesslog.AccessLogHandler.level=INFO
954
- io.helidon.webserver.accesslog.AccessLogHandler.pattern=access.log
955
- io.helidon.webserver.accesslog.AccessLogHandler.append=true
956
-
957
- io.helidon.webserver.AccessLog.level=INFO
958
- io.helidon.webserver.AccessLog.useParentHandlers=false
959
- io.helidon.webserver.AccessLog.handlers=io.helidon.webserver.accesslog.AccessLogHandler
960
- ----
857
+ include::{rootdir}/includes/server/access-log-config-common.adoc[leveloffset=+1]
961
858
962
859
== TLS Configuration
963
860
0 commit comments