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