From bef21f7e234f6dc1b334bb15c6e621ef58d19f91 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Tue, 23 Jan 2018 15:13:55 +0100 Subject: [PATCH 01/10] Added http server access log --- .../src/main/resources/logback.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/knotx-example/knotx-example-app/src/main/resources/logback.xml b/knotx-example/knotx-example-app/src/main/resources/logback.xml index c8126b4e..20a17527 100644 --- a/knotx-example/knotx-example-app/src/main/resources/logback.xml +++ b/knotx-example/knotx-example-app/src/main/resources/logback.xml @@ -38,6 +38,20 @@ + + access.log + true + + true + + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + + + + + + + From ea70d815ecc1772ed8b634af1c08574863305b7d Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Tue, 23 Jan 2018 15:39:28 +0100 Subject: [PATCH 02/10] Updated the documentation & logback --- documentation/src/main/wiki/Server.md | 57 +++++++++++++++++++ .../src/main/resources/logback.xml | 2 +- .../knotx/server/KnotxRepositoryHandler.java | 11 +++- .../io/knotx/server/KnotxServerVerticle.java | 9 ++- .../server/configuration/AccessLogConfig.java | 49 ++++++++++++++++ .../KnotxServerConfiguration.java | 8 +++ .../src/main/resources/logback.xml | 16 +++++- 7 files changed, 144 insertions(+), 8 deletions(-) create mode 100644 knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java diff --git a/documentation/src/main/wiki/Server.md b/documentation/src/main/wiki/Server.md index 0d4fa620..6cf27390 100644 --- a/documentation/src/main/wiki/Server.md +++ b/documentation/src/main/wiki/Server.md @@ -159,6 +159,7 @@ Main server options available. | `csrf` | `KnotxCSRFConfiguration` | | Configuration of the CSRF tokens | | `defaultFlow` | `KnotxFlowConfiguration` | ✔ | Configuration of [[default Knot.X routing|KnotRouting]] | | `customFlow` | `KnotxFlowConfiguration` | | Configuration of [[Gateway Mode|GatewayMode]] | +| `accessLog` | `AccessLogConfiguration` | | Configuration of the KnotxServer access log | ### KnotxServerCustomHeader options Name | Type | Mandatory | Description | @@ -214,6 +215,15 @@ The `repositories`, `splitter` and `assembler` verticles are specific to the def | `address` | `String` | ✔ | Event bus address of the **Knot** verticle | | `onTransition` | `KnotRouteEntry` | | Describes routing to addresses of other Knots based on the transition trigger returned from current Knot.
`"onTransition": { "go-d": {}, "go-e": {} }` | + +### AccessLogConfiguration options +| Name | Type | Mandatory | Description | +|-------:|:-------:|:-------: |-------| +| `enabled` | `boolean` | | Enable/Disable access log. Default is `true` | +| `immediate` | `boolean` | | Log before request or after. Default is `false` - log after request | +| `format` | `String` | | Format of the access log. Allowed valueds are `DEFAULT`, `SHORT`, `TINY`. Default tries to log in a format similar to Apache log format, while the other 2 are more suited to development mode. Default format is `DEFAULT` | + + ### Vert.x HTTP Server configurations Besides Knot.x specific configurations as mentioned above, the `config` field might have added Vert.x configurations related to the HTTP server. @@ -345,3 +355,50 @@ for eventubs requests that come from `KnotxServer`. } } ``` + +### Configure access log +Knot.x uses a default Logging handler from the Vert.x web distribution that allows to log all incomming requests to the Http server. +It supports three log line formats that are: +- DEFAULT that tries to log in a format similar to Apache log format +`127.0.0.1 - - [Tue, 23 Jan 2018 14:16:34 GMT] "GET /content/local/simple.html HTTP/1.1" 200 2963 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"` +- SHORT +`127.0.0.1 - GET /content/local/simple.html HTTP/1.1 200 2963 - 19 ms` +- TINY +`GET /content/local/simple.html 200 2963 - 24 ms` + +By default access log is enabled with a `DEFAULT` format. If you want to change it, just add access logging section on the KnotxServer configuration in your application.json config file : +```json +{ + "config": { + "knotx:io.knotx.KnotxServer": { + "options": { + "config": { + "accessLog": { + "format": "TINY" + } + } + } + } + } +} +``` +In order to log the access log to a separate file, just configure your logger in `logback.xml` file as follows +```xml + + access.log + true + + true + + %msg%n + + + + + + +``` +This configures log appender as file, with the pattern being just a message. +Next step, is to add logger for `io.vertx.ext.web.handler.impl.LoggerHandlerImpl` to be flushed out into your new appender. + +See [logback.xml](https://github.com/Cognifide/knotx/blob/master/knotx-example/knotx-example-app/src/main/resources/logback.xml) from the example app as an example. diff --git a/knotx-example/knotx-example-app/src/main/resources/logback.xml b/knotx-example/knotx-example-app/src/main/resources/logback.xml index 20a17527..f4123d75 100644 --- a/knotx-example/knotx-example-app/src/main/resources/logback.xml +++ b/knotx-example/knotx-example-app/src/main/resources/logback.xml @@ -44,7 +44,7 @@ true - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + %msg%n diff --git a/knotx-server/src/main/java/io/knotx/server/KnotxRepositoryHandler.java b/knotx-server/src/main/java/io/knotx/server/KnotxRepositoryHandler.java index 6cd72511..3ea47504 100644 --- a/knotx-server/src/main/java/io/knotx/server/KnotxRepositoryHandler.java +++ b/knotx-server/src/main/java/io/knotx/server/KnotxRepositoryHandler.java @@ -60,7 +60,8 @@ public void handle(RoutingContext context) { final KnotContext knotContext = context.get(KnotContext.KEY); if (repositoryEntry.isPresent()) { - proxies.computeIfAbsent( repositoryEntry.get().address(),adr -> RepositoryConnectorProxy.createProxyWithOptions(vertx, adr, configuration.getDeliveryOptions())) + proxies.computeIfAbsent(repositoryEntry.get().address(), adr -> RepositoryConnectorProxy + .createProxyWithOptions(vertx, adr, configuration.getDeliveryOptions())) .rxProcess(knotContext.getClientRequest()) .doOnSuccess(this::traceMessage) .subscribe( @@ -91,8 +92,12 @@ void handleRepositoryResponse(ClientResponse repoResponse, RoutingContext contex private void endResponse(ClientResponse repoResponse, RoutingContext context) { writeHeaders(context.response(), repoResponse.getHeaders()); - context.response().setStatusCode(repoResponse.getStatusCode()) - .end(Buffer.newInstance(repoResponse.getBody())); + context.response().setStatusCode(repoResponse.getStatusCode()); + if (repoResponse.getBody() != null) { + context.response().end(Buffer.newInstance(repoResponse.getBody())); + } else { + context.response().end(); + } } private boolean isSuccessResponse(ClientResponse repoResponse) { diff --git a/knotx-server/src/main/java/io/knotx/server/KnotxServerVerticle.java b/knotx-server/src/main/java/io/knotx/server/KnotxServerVerticle.java index 74dae794..82ee1b2e 100644 --- a/knotx-server/src/main/java/io/knotx/server/KnotxServerVerticle.java +++ b/knotx-server/src/main/java/io/knotx/server/KnotxServerVerticle.java @@ -31,8 +31,7 @@ import io.vertx.reactivex.ext.web.handler.CSRFHandler; import io.vertx.reactivex.ext.web.handler.CookieHandler; import io.vertx.reactivex.ext.web.handler.ErrorHandler; -import java.io.IOException; -import java.net.URISyntaxException; +import io.vertx.reactivex.ext.web.handler.LoggerHandler; public class KnotxServerVerticle extends AbstractVerticle { @@ -47,7 +46,7 @@ public void init(Vertx vertx, Context context) { } @Override - public void start(Future fut) throws IOException, URISyntaxException { + public void start(Future fut) { LOGGER.info("Starting <{}>", this.getClass().getSimpleName()); KnotxCSRFConfig csrfConfig = configuration.getCsrfConfig(); CSRFHandler csrfHandler = CSRFHandler.create(csrfConfig.getSecret()) @@ -58,6 +57,10 @@ public void start(Future fut) throws IOException, URISyntaxException { .setTimeout(csrfConfig.getTimeout()); Router router = Router.router(vertx); + if (configuration.getAccessLogConfig().isEnabled()) { + router.route().handler(LoggerHandler.create(configuration.getAccessLogConfig().isImmediate(), + configuration.getAccessLogConfig().getFormat())); + } router.route().handler(KnotxHeaderHandler.create(configuration)); router.route().handler(SupportedMethodsAndPathsHandler.create(configuration)); router.route().handler(CookieHandler.create()); diff --git a/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java new file mode 100644 index 00000000..2a6eec91 --- /dev/null +++ b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.knotx.server.configuration; + +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.handler.LoggerFormat; + +public class AccessLogConfig { + + public static final boolean DEFAULT_ENABLED = true; + public static final boolean DEFAULT_LOGGER_IMMEDIATE = false; + public static final String DEFAULT_LOGGER_FORMAT = LoggerFormat.DEFAULT.toString(); + + private boolean enabled; + private boolean immediate; + private LoggerFormat format; + + public AccessLogConfig(JsonObject config) { + enabled = config.getBoolean("enabled", DEFAULT_ENABLED); + immediate = config.getBoolean("immediate", DEFAULT_LOGGER_IMMEDIATE); + format = LoggerFormat + .valueOf(config.getString("format", DEFAULT_LOGGER_FORMAT).toUpperCase()); + } + + public boolean isEnabled() { + return enabled; + } + + public boolean isImmediate() { + return immediate; + } + + public LoggerFormat getFormat() { + return format; + } +} diff --git a/knotx-server/src/main/java/io/knotx/server/configuration/KnotxServerConfiguration.java b/knotx-server/src/main/java/io/knotx/server/configuration/KnotxServerConfiguration.java index 5ca918a5..560b3ce1 100644 --- a/knotx-server/src/main/java/io/knotx/server/configuration/KnotxServerConfiguration.java +++ b/knotx-server/src/main/java/io/knotx/server/configuration/KnotxServerConfiguration.java @@ -46,6 +46,8 @@ public class KnotxServerConfiguration { private KnotxCSRFConfig csrfConfig; + private AccessLogConfig accessLogConfig; + public KnotxServerConfiguration(JsonObject config) { displayExceptionDetails = config.getBoolean("displayExceptionDetails", false); @@ -67,6 +69,8 @@ public KnotxServerConfiguration(JsonObject config) { config.getJsonObject("deliveryOptions")) : new DeliveryOptions(); csrfConfig = new KnotxCSRFConfig(config.getJsonObject("csrf", new JsonObject())); + + accessLogConfig = new AccessLogConfig(config.getJsonObject("accessLog", new JsonObject())); } public boolean displayExceptionDetails() { @@ -108,4 +112,8 @@ public KnotxCSRFConfig getCsrfConfig() { public Long getFileUploadLimit() { return fileUploadLimit; } + + public AccessLogConfig getAccessLogConfig() { + return accessLogConfig; + } } diff --git a/knotx-standalone/src/main/resources/logback.xml b/knotx-standalone/src/main/resources/logback.xml index 893a0fbc..08e14a37 100644 --- a/knotx-standalone/src/main/resources/logback.xml +++ b/knotx-standalone/src/main/resources/logback.xml @@ -26,8 +26,22 @@ + + access.log + true + + true + + %msg%n + + + + + + + + additivity="false"> From e953b19b4124cad93edc6d3d5ab556552edadae3 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Tue, 23 Jan 2018 15:48:22 +0100 Subject: [PATCH 03/10] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5015729d..84795ad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ List of changes that are finished but not yet released in any final version. - [PR-371](https://github.com/Cognifide/knotx/pull/371) - Fixed debug logging of HTTP Repository Connector - [PR-372](https://github.com/Cognifide/knotx/pull/372) - Added cache for compiled Handlebars snippets - [PR-374](https://github.com/Cognifide/knotx/pull/374) - Enable keepAlive connection in http client options + - [PR-379](https://github.com/Cognifide/knotx/pull/379) - Added access logging capabilities to the Knotx HTTP Server ## Version 1.1.2 - [PR-318](https://github.com/Cognifide/knotx/pull/318) - Knot.x returns exit code `30` in case of missing config From 0ccaa88754653b7a2d1f006083e43518735ac308 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Wed, 24 Jan 2018 14:07:46 +0100 Subject: [PATCH 04/10] Abstract logger configurations, make it more usable --- CHANGELOG.md | 2 +- .../io/knotx/launcher/LogbackLauncher.java | 10 +++- .../logging/logback/access-file-appender.xml | 35 +++++++++++++ .../io/knotx/logging/logback/access.xml | 31 ++++++++++++ .../io/knotx/logging/logback/base.xml | 37 ++++++++++++++ .../logging/logback/console-appender.xml | 29 +++++++++++ .../io/knotx/logging/logback/defaults.xml | 30 +++++++++++ .../knotx/logging/logback/file-appender.xml | 35 +++++++++++++ .../logging/logback/netty-file-appender.xml | 35 +++++++++++++ .../io/knotx/logging/logback/netty.xml | 31 ++++++++++++ .../example.io.knotx.KnotxServer.json | 3 +- .../src/main/resources/knotx-example-app.json | 12 +++++ .../src/main/resources/logback.xml | 50 ++++++------------- .../src/main/resources/logback.xml | 33 ++---------- 14 files changed, 304 insertions(+), 69 deletions(-) create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/access-file-appender.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/access.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/base.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/console-appender.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/file-appender.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/netty-file-appender.xml create mode 100644 knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 84795ad3..47b47151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ List of changes that are finished but not yet released in any final version. - [PR-371](https://github.com/Cognifide/knotx/pull/371) - Fixed debug logging of HTTP Repository Connector - [PR-372](https://github.com/Cognifide/knotx/pull/372) - Added cache for compiled Handlebars snippets - [PR-374](https://github.com/Cognifide/knotx/pull/374) - Enable keepAlive connection in http client options - - [PR-379](https://github.com/Cognifide/knotx/pull/379) - Added access logging capabilities to the Knotx HTTP Server + - [PR-379](https://github.com/Cognifide/knotx/pull/379) - Added access logging capabilities to the Knotx HTTP Server. Establish standard configuration of logback logger. ## Version 1.1.2 - [PR-318](https://github.com/Cognifide/knotx/pull/318) - Knot.x returns exit code `30` in case of missing config diff --git a/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java b/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java index bd6a0494..76af684c 100644 --- a/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java +++ b/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java @@ -18,6 +18,8 @@ import io.vertx.core.Launcher; import io.vertx.core.impl.launcher.commands.ExecUtils; import io.vertx.core.json.JsonObject; +import java.io.FileNotFoundException; +import java.io.PrintStream; public class LogbackLauncher extends Launcher { @@ -26,7 +28,13 @@ public class LogbackLauncher extends Launcher { */ public static final int KNOTX_MISSING_OR_EMPTY_CONFIGURATION_EXIT_CODE = 30; - public static void main(String[] args) { + public static void main(String[] args){ + try { + System.setOut(new PrintStream("/Users/marcin.czeczko/Cognifide/Projects/knotx/knotx-example/knotx-example-app/stdout.log")); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory"); new LogbackLauncher().dispatch(args); diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/access-file-appender.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/access-file-appender.xml new file mode 100644 index 00000000..a6829d28 --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/access-file-appender.xml @@ -0,0 +1,35 @@ + + + + + + + + ${FILE_ACCESS_LOG_PATTERN} + + ${ACCESS_LOG_FILE} + + ${ACCESS_LOG_FILE}.%d{yyyy-MM-dd}.%i.gz + ${ACCESS_LOG_FILE_MAX_SIZE:-10MB} + ${ACCESS_LOG_FILE_MAX_HISTORY:-0} + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml new file mode 100644 index 00000000..03bc63fb --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml new file mode 100644 index 00000000..210e2624 --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/console-appender.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/console-appender.xml new file mode 100644 index 00000000..85cdc95e --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/console-appender.xml @@ -0,0 +1,29 @@ + + + + + + + + ${CONSOLE_KNOTX_LOG_PATTERN} + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml new file mode 100644 index 00000000..603c7dcb --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/file-appender.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/file-appender.xml new file mode 100644 index 00000000..a9e1255f --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/file-appender.xml @@ -0,0 +1,35 @@ + + + + + + + + ${FILE_KNOTX_LOG_PATTERN} + + ${KNOTX_LOG_FILE} + + ${KNOTX_LOG_FILE}.%d{yyyy-MM-dd}.%i.gz + ${KNOTX_LOG_FILE_MAX_SIZE:-10MB} + ${KNOTX_LOG_FILE_MAX_HISTORY:-0} + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/netty-file-appender.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/netty-file-appender.xml new file mode 100644 index 00000000..ac2dfc06 --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/netty-file-appender.xml @@ -0,0 +1,35 @@ + + + + + + + + ${FILE_NETTY_LOG_PATTERN} + + ${NETTY_LOG_FILE} + + ${NETTY_LOG_FILE}.%d{yyyy-MM-dd}.%i.gz + ${NETTY_LOG_FILE_MAX_SIZE:-10MB} + ${NETTY_LOG_FILE_MAX_HISTORY:-0} + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml new file mode 100644 index 00000000..6589be0a --- /dev/null +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/knotx-example/knotx-example-app/src/main/resources/example.io.knotx.KnotxServer.json b/knotx-example/knotx-example-app/src/main/resources/example.io.knotx.KnotxServer.json index 721c174e..e7a80912 100644 --- a/knotx-example/knotx-example-app/src/main/resources/example.io.knotx.KnotxServer.json +++ b/knotx-example/knotx-example-app/src/main/resources/example.io.knotx.KnotxServer.json @@ -4,7 +4,8 @@ "config": { "serverOptions": { "port": 8092, - "keyStoreOptions": {} + "keyStoreOptions": {}, + "logActivity": true }, "displayExceptionDetails": true, "customResponseHeader": { diff --git a/knotx-example/knotx-example-app/src/main/resources/knotx-example-app.json b/knotx-example/knotx-example-app/src/main/resources/knotx-example-app.json index ce0e42c0..9599235f 100644 --- a/knotx-example/knotx-example-app/src/main/resources/knotx-example-app.json +++ b/knotx-example/knotx-example-app/src/main/resources/knotx-example-app.json @@ -19,6 +19,15 @@ "knotx:io.knotx.ResponseProviderKnot" ], "config": { + "knotx:io.knotx.HttpServiceAdapter": { + "options": { + "config": { + "clientOptions": { + "logActivity": true + } + } + } + }, "knotx:io.knotx.ServiceKnot": { "options": { "config": { @@ -56,6 +65,9 @@ "knotx:example.io.knotx.HttpActionAdapter": { "options": { "config": { + "clientOptions": { + "logActivity": true + }, "allowedRequestHeaders": [ "Cookie", "Content-Type", diff --git a/knotx-example/knotx-example-app/src/main/resources/logback.xml b/knotx-example/knotx-example-app/src/main/resources/logback.xml index f4123d75..02d4cc65 100644 --- a/knotx-example/knotx-example-app/src/main/resources/logback.xml +++ b/knotx-example/knotx-example-app/src/main/resources/logback.xml @@ -17,52 +17,30 @@ --> - + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - + + + - - netty-wire.log - true + + - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - access.log + + logger.log true true + - %msg%n + %-4relative [%thread] %-5level %logger{35} - %msg%n - - - - - - + + - - - - - - - - diff --git a/knotx-standalone/src/main/resources/logback.xml b/knotx-standalone/src/main/resources/logback.xml index 08e14a37..025c093a 100644 --- a/knotx-standalone/src/main/resources/logback.xml +++ b/knotx-standalone/src/main/resources/logback.xml @@ -17,36 +17,9 @@ --> + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - access.log - true - - true - - %msg%n - - - - - - - - - - - - - - + + From 7a973a3e1d56980d11b1e1778a89f0c10e397e02 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Wed, 24 Jan 2018 23:54:36 +0100 Subject: [PATCH 05/10] Clean up logback, start documentation about logging --- documentation/src/main/wiki/Home.md | 1 + documentation/src/main/wiki/Logging.md | 0 documentation/src/main/wiki/_Sidebar.md | 1 + .../io/knotx/launcher/LogbackLauncher.java | 6 ------ .../io/knotx/logging/logback/access.xml | 2 +- .../io/knotx/logging/logback/base.xml | 4 ---- .../io/knotx/logging/logback/defaults.xml | 4 ++++ .../io/knotx/logging/logback/netty.xml | 2 +- .../src/main/resources/logback.xml | 19 ------------------- .../src/main/resources/logback.xml | 3 --- 10 files changed, 8 insertions(+), 34 deletions(-) create mode 100644 documentation/src/main/wiki/Logging.md diff --git a/documentation/src/main/wiki/Home.md b/documentation/src/main/wiki/Home.md index 87302a84..71cfbe62 100644 --- a/documentation/src/main/wiki/Home.md +++ b/documentation/src/main/wiki/Home.md @@ -31,6 +31,7 @@ User documentation is available at [http://knotx.io](http://knotx.io/). * [[Mocks|Mocks]] * [[Knot.x Deployment|KnotxDeployment]] * [[Knot.x Tuning|KnotxTuning]] +* [[Logging|Logging]] * [[Performance|PerformanceTests]] * [[Performance Tests Methodology|PerformanceTestsMethodology]] * [[Performance Tests Summary|PerformanceTestsSummary]] diff --git a/documentation/src/main/wiki/Logging.md b/documentation/src/main/wiki/Logging.md new file mode 100644 index 00000000..e69de29b diff --git a/documentation/src/main/wiki/_Sidebar.md b/documentation/src/main/wiki/_Sidebar.md index ad0abf15..0bab6e9b 100644 --- a/documentation/src/main/wiki/_Sidebar.md +++ b/documentation/src/main/wiki/_Sidebar.md @@ -27,6 +27,7 @@ * [[Mocks|Mocks]] * [[Knot.x Deployment|KnotxDeployment]] * [[Knot.x Tuning|KnotxTuning]] + * [[Logging|Logging]] * [[Performance|PerformanceTests]] * [[Performance Tests Methodology|PerformanceTestsMethodology]] * [[Performance Tests Summary|PerformanceTestsSummary]] diff --git a/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java b/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java index 76af684c..28382fc4 100644 --- a/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java +++ b/knotx-core/src/main/java/io/knotx/launcher/LogbackLauncher.java @@ -29,12 +29,6 @@ public class LogbackLauncher extends Launcher { public static final int KNOTX_MISSING_OR_EMPTY_CONFIGURATION_EXIT_CODE = 30; public static void main(String[] args){ - try { - System.setOut(new PrintStream("/Users/marcin.czeczko/Cognifide/Projects/knotx/knotx-example/knotx-example-app/stdout.log")); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory"); new LogbackLauncher().dispatch(args); diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml index 03bc63fb..8b1b30a9 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/access.xml @@ -22,7 +22,7 @@ File appender logback configuration for knotx access logs provided for import - + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml index 210e2624..05c04af8 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml @@ -22,11 +22,7 @@ Base logback configuration for knot.x - - - - diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml index 603c7dcb..8a4f9917 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml @@ -21,9 +21,13 @@ Default logback configuration provided for import --> + + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml index 6589be0a..c5907824 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/netty.xml @@ -22,7 +22,7 @@ File appender logback configuration for netty debug logs provided for import - + diff --git a/knotx-example/knotx-example-app/src/main/resources/logback.xml b/knotx-example/knotx-example-app/src/main/resources/logback.xml index 02d4cc65..3f1563b8 100644 --- a/knotx-example/knotx-example-app/src/main/resources/logback.xml +++ b/knotx-example/knotx-example-app/src/main/resources/logback.xml @@ -17,9 +17,6 @@ --> - - - @@ -27,20 +24,4 @@ - - logger.log - true - - true - - - %-4relative [%thread] %-5level %logger{35} - %msg%n - - - - - - - diff --git a/knotx-standalone/src/main/resources/logback.xml b/knotx-standalone/src/main/resources/logback.xml index 025c093a..f94b2e26 100644 --- a/knotx-standalone/src/main/resources/logback.xml +++ b/knotx-standalone/src/main/resources/logback.xml @@ -17,9 +17,6 @@ --> - - - From ddb0f0b18dcf2f8e61b4475e34d988d29cbf7e76 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Thu, 25 Jan 2018 00:22:21 +0100 Subject: [PATCH 06/10] Logging documentation - in-progress... --- documentation/src/main/wiki/Logging.md | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/documentation/src/main/wiki/Logging.md b/documentation/src/main/wiki/Logging.md index e69de29b..8ff2cfd2 100644 --- a/documentation/src/main/wiki/Logging.md +++ b/documentation/src/main/wiki/Logging.md @@ -0,0 +1,51 @@ +# Logging +By default Knot.x picks up the logger configuration from its default location for the system (e.g. classpath:logback.xml), but you can set the location of the config file through `logback.configurationFile` system property. +``` +java -Dlogback.configurationFile=/path/to/logback.xml -jar ... +``` +- ### TBD: what types of logs availble (knotx, access, netty) +- ### TBD: how it logs by default + +## Configure Logback +Knot.x provides a default base configuration that you can include if you just want to set levels, e.g. + +```xml + + + + + +``` +The `base.xml` file uses useful System properties which the Logback takes care of creating for you. These are: +- `${LOG_PATH}` - represents a directory for log files to live in). +- #### TBD ###### + +See the [default `base.xml`](https://github.com/Cognifide/knotx/blob/master/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml) configuration for details. + +## Configure logback for file only output +If you want to disable console logging and write output only to a file you need a custom logback.xml that imports file-appender.xml but not console-appender.xml: + +```xml + + + + + + + + +``` + +You also need to set `LOG_PATH` System property to point one where the file will be logged. As an alternative you can set that property inside your logback.xml +```xml + + + + ... + +``` + +## Configure logback to log into multiple files + +## Extras +Logback logger brings a tremendous amount of possibilities how to store your logs. It's impossible to present here all possibilities, so the best way would be a [Logback Documentation](https://logback.qos.ch/manual/index.html). From 82981f2115563e4e57b296b0bdc6472795406a86 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Thu, 25 Jan 2018 00:38:19 +0100 Subject: [PATCH 07/10] PR fixed, documentation about logging - in-progress --- documentation/src/main/wiki/Server.md | 4 ++-- .../java/io/knotx/server/configuration/AccessLogConfig.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/documentation/src/main/wiki/Server.md b/documentation/src/main/wiki/Server.md index 6cf27390..a7df1a46 100644 --- a/documentation/src/main/wiki/Server.md +++ b/documentation/src/main/wiki/Server.md @@ -221,7 +221,7 @@ The `repositories`, `splitter` and `assembler` verticles are specific to the def |-------:|:-------:|:-------: |-------| | `enabled` | `boolean` | | Enable/Disable access log. Default is `true` | | `immediate` | `boolean` | | Log before request or after. Default is `false` - log after request | -| `format` | `String` | | Format of the access log. Allowed valueds are `DEFAULT`, `SHORT`, `TINY`. Default tries to log in a format similar to Apache log format, while the other 2 are more suited to development mode. Default format is `DEFAULT` | +| `format` | `String` | | Format of the access log. Allowed valueds are `DEFAULT`, `SHORT`, `TINY`. See [[Configure Access Log|#configure-access-log]]. Default format is `DEFAULT` | ### Vert.x HTTP Server configurations @@ -359,7 +359,7 @@ for eventubs requests that come from `KnotxServer`. ### Configure access log Knot.x uses a default Logging handler from the Vert.x web distribution that allows to log all incomming requests to the Http server. It supports three log line formats that are: -- DEFAULT that tries to log in a format similar to Apache log format +- DEFAULT that tries to log in a format similar to Apache log format (APACHE/NCSA COMBINED LOG FORMAT) `127.0.0.1 - - [Tue, 23 Jan 2018 14:16:34 GMT] "GET /content/local/simple.html HTTP/1.1" 200 2963 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"` - SHORT `127.0.0.1 - GET /content/local/simple.html HTTP/1.1 200 2963 - 19 ms` diff --git a/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java index 2a6eec91..12d27982 100644 --- a/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java +++ b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java @@ -20,9 +20,9 @@ public class AccessLogConfig { - public static final boolean DEFAULT_ENABLED = true; - public static final boolean DEFAULT_LOGGER_IMMEDIATE = false; - public static final String DEFAULT_LOGGER_FORMAT = LoggerFormat.DEFAULT.toString(); + private static final boolean DEFAULT_ENABLED = true; + private static final boolean DEFAULT_LOGGER_IMMEDIATE = false; + private static final String DEFAULT_LOGGER_FORMAT = LoggerFormat.DEFAULT.toString(); private boolean enabled; private boolean immediate; From 20a18076a1ca934c5283ffef76caf2d4e893314c Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Thu, 25 Jan 2018 10:26:11 +0100 Subject: [PATCH 08/10] Udpated logging documentation --- documentation/src/main/wiki/Logging.md | 157 ++++++++++++++++-- documentation/src/main/wiki/Server.md | 23 +-- documentation/src/main/wiki/UpgradeNotes.md | 4 +- .../src/test/resources/logback-test.xml | 22 +-- .../src/test/resources/logback-test.xml | 22 +-- .../io/knotx/logging/logback/base.xml | 12 +- .../io/knotx/logging/logback/defaults.xml | 2 + .../src/test/resources/logback-test.xml | 22 +-- .../src/main/resources/logback.xml | 1 - .../src/test/resources/logback-test.xml | 22 +-- .../src/test/resources/logback-test.xml | 22 +-- .../src/test/resources/logback-test.xml | 22 +-- .../src/test/resources/logback-test.xml | 22 +-- .../src/test/resources/logback-test.xml | 22 +-- .../src/main/resources/logback.xml | 8 +- 15 files changed, 217 insertions(+), 166 deletions(-) diff --git a/documentation/src/main/wiki/Logging.md b/documentation/src/main/wiki/Logging.md index 8ff2cfd2..36fc878f 100644 --- a/documentation/src/main/wiki/Logging.md +++ b/documentation/src/main/wiki/Logging.md @@ -1,51 +1,178 @@ # Logging -By default Knot.x picks up the logger configuration from its default location for the system (e.g. classpath:logback.xml), but you can set the location of the config file through `logback.configurationFile` system property. +By default Knot.x picks up the logger configuration from its default location for the system (e.g. classpath:logback.xml), +but you can set the location of the config file through `logback.configurationFile` system property. ``` java -Dlogback.configurationFile=/path/to/logback.xml -jar ... ``` -- ### TBD: what types of logs availble (knotx, access, netty) -- ### TBD: how it logs by default +Knot.x core provides preconfigured three log files: +- `knotx.log` that logs all **ERROR** messages from the Netty & Vert.x and **INFO** messages from Knot.x application. Enabled by default on Knot.x standalone +- `knotx-access.log` that logs all HTTP requests/responses to the Knot.x HTTP Server. Enabled by default on Knot.x standalone +- `knotx-netty.log` that logs all network activity (logged by the Netty). Not enabled on Knot.x standalone. See [[Log network activity|#log-network-activity]] on how to enable it. + +All logs are configured by default: +- To log both to file and console +- Log files are rolled over every day or if the log file exceeds 10MB +- Rolled files are automatically compressed +- History log files are kept forever + +A default configuration can be overriden in order to meet your log policy. See [[Configure logback|#configure-logback]] for details. ## Configure Logback -Knot.x provides a default base configuration that you can include if you just want to set levels, e.g. +Knot.x provides a default set of logback configurations that you can include, if you just want to set levels, or create your own specific loggers, e.g. ```xml - - + + + + + + + + + + ``` -The `base.xml` file uses useful System properties which the Logback takes care of creating for you. These are: -- `${LOG_PATH}` - represents a directory for log files to live in). -- #### TBD ###### +Will create console & file logger for Knot.x logs. Besides that there are other includes that brings new logs, these are: +- `io/knotx/logging/logback/access.xml` - access log +- `io/knotx/logging/logback/netty.xml` - network activity logs + +All those configurations uses useful System properties which the Logback takes care of creating for you. These are: +- `${LOG_PATH}` - represents a directory for log files to live in, for knotx, access & netty logs. It's set with the value from `LOG_PATH` System property, or from your own logback.xml file. If none of these specified, logs to the current working directory `/logs` subfolder. +- `${KNOTX_LOG_FILE}`, `${ACCESS_LOG_FILE}`, `${NETTY_LOG_FILE}` - Ignores `LOG_PATH` and use that property to specify actual location for the knotx, access & netty log files (e.g. `/var/logs/knotx.log`, or `/var/logs/access.log`) +- `${KNOTX_LOG_DATEFORMAT_PATTERN}` - Allows to specify a different date-time format for log entries in `knotx.log` and `knotx-netty.log` files only. If not specified, `yyyy-MM-dd HH:mm:ss.SSS` is used. +- `${CONSOLE_KNOTX_LOG_PATTERN}` - Allows to override a default log pattern for console logging. +- `${FILE_KNOTX_LOG_PATTERN}`, `${FILE_ACCESS_LOG_PATTERN}`, `${FILE_NETTY_LOG_PATTERN}` - Allows to override a default log pattern for knotx, access & netty logs. +- `${KNOTX_LOG_FILE_MAX_SIZE}`, `${ACCESS_LOG_FILE_MAX_SIZE}`, `${NETTY_LOG_FILE_MAX_SIZE}` - Allows to define a maximum size of knotx, access & netty log files. If not specified, a max size is `10MB` +- `${KNOTX_LOG_FILE_MAX_HISTORY}`, `${ACCESS_LOG_FILE_MAX_HISTORY}`, `${NETTY_LOG_FILE_MAX_HISTORY}` - Allows to define a maximum amount of archived log files kept in the log folder (for knotx, access & netty logs). If not specified, it keeps files forever. -See the [default `base.xml`](https://github.com/Cognifide/knotx/blob/master/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml) configuration for details. +See the [Knot.x core logback settings](https://github.com/Cognifide/knotx/blob/master/knotx-core/src/main/resources/io/knotx/logging/logback/) configuration files for details. ## Configure logback for file only output -If you want to disable console logging and write output only to a file you need a custom logback.xml that imports file-appender.xml but not console-appender.xml: +In a production system, you want to disable console logging and write output only to a file both for knotx & access logs. +You need to create a custom `logback.xml` that imports `file-appender.xml` but not `console-appender.xml`: ```xml + + ``` -You also need to set `LOG_PATH` System property to point one where the file will be logged. As an alternative you can set that property inside your logback.xml +**NOTE: Do not forgot to specify usage of your custom logback file through `-Dlogback.configurationFile` system property.** + +Additionally, you want to specify a location of log files in your file system. And roll over policy to keep last 30 archived log files. +You can do this, through your custom logback file: ```xml + + + + + ... + +``` +Or, you can provide those settings through System properties: +``` +-DLOG_PATH=/path/to/logs -DKNOTX_LOG_FILE_MAX_HISTORY=30 -DACCESS_LOG_FILE_MAX_HISTORY=30 +``` +Or, even you can mix both approaches. So define default settings inside logback, and configure to respect new System properties you can use to override +```xml + + + + + ... ``` +And your System property, that will set different log path, and max history for both log files to `100`: +``` +-Dmy.logs=/other/path -Dmy.logs.history=100 +``` +As you can see, Logback logger brings a tremendous amount of possibilities how to configure your logs. +It's impossible to present here all the possibilities, so the best way would be to study [Logback Documentation](https://logback.qos.ch/manual/index.html). -## Configure logback to log into multiple files +## Log network activity +Network activity (logged by Netty) logger settings are provided by the Knot.x core. In order to log it, you need to use your custom logback.xml file and configure it as follows +```xml + + + + + + + + + + + + + +``` +Additionally, in your knot.x json configuration file, you need to enable logging network activity. You can enable this both for HTTP server as well as HTTP clients used. +- To enable it for server, just overwrite KnotxServer configuration: +```json +"config": { + "serverOptions": { + "logActivity": true + } +} +``` +- To enable it for HTTP Clients, just overwrite any or all service adapter configurations: +```json +"config": { + "clientOptions": { + "logActivity": true + } +} +``` -## Extras -Logback logger brings a tremendous amount of possibilities how to store your logs. It's impossible to present here all possibilities, so the best way would be a [Logback Documentation](https://logback.qos.ch/manual/index.html). +## Configure logback to log my specific package +If you added your own Knot's, Adapters or any other extension to the Knot.x you want to have this information to be logged in your log files. +```xml + + + + + + + + + + + + + + + +``` +- Add `logger` for your package or class, define a level of logs +- Specify `FILE` appender as a logs target. +Your logs will appear in the `knotx.log` + +However, you might wanted to log your package logs into a separate file, to not polute `knotx.log`. +- create your own file appender (see `io/knotx/logging/logback/file-appender.xml` as an example) with the name e.g. `MY_FILE` +- bind your logger to `MY_FILE` appender +- set logger to `additivity="false"`, so your logs will go just to your new file. If specified to `true` logs will go to the parent logger into `knotx.log` files too. + +```xml + + + + + + + + +``` diff --git a/documentation/src/main/wiki/Server.md b/documentation/src/main/wiki/Server.md index a7df1a46..765acc65 100644 --- a/documentation/src/main/wiki/Server.md +++ b/documentation/src/main/wiki/Server.md @@ -359,7 +359,7 @@ for eventubs requests that come from `KnotxServer`. ### Configure access log Knot.x uses a default Logging handler from the Vert.x web distribution that allows to log all incomming requests to the Http server. It supports three log line formats that are: -- DEFAULT that tries to log in a format similar to Apache log format (APACHE/NCSA COMBINED LOG FORMAT) +- DEFAULT that tries to log in a format similar to Apache log format (APACHE/NCSA COMBINED LOG FORMAT) as in the example `127.0.0.1 - - [Tue, 23 Jan 2018 14:16:34 GMT] "GET /content/local/simple.html HTTP/1.1" 200 2963 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"` - SHORT `127.0.0.1 - GET /content/local/simple.html HTTP/1.1 200 2963 - 19 ms` @@ -382,23 +382,4 @@ By default access log is enabled with a `DEFAULT` format. If you want to change } } ``` -In order to log the access log to a separate file, just configure your logger in `logback.xml` file as follows -```xml - - access.log - true - - true - - %msg%n - - - - - - -``` -This configures log appender as file, with the pattern being just a message. -Next step, is to add logger for `io.vertx.ext.web.handler.impl.LoggerHandlerImpl` to be flushed out into your new appender. - -See [logback.xml](https://github.com/Cognifide/knotx/blob/master/knotx-example/knotx-example-app/src/main/resources/logback.xml) from the example app as an example. +In order to configure logger for access log, see [[Logging|Logging]]. diff --git a/documentation/src/main/wiki/UpgradeNotes.md b/documentation/src/main/wiki/UpgradeNotes.md index 9f86c14f..8603f258 100644 --- a/documentation/src/main/wiki/UpgradeNotes.md +++ b/documentation/src/main/wiki/UpgradeNotes.md @@ -18,7 +18,9 @@ For more details see documentation sections in [[Server|Server#vertx-event-bus-d in order to receive errors stack traces. - [PR-369](https://github.com/Cognifide/knotx/pull/369) - Better support for SSL for Repository Connector. Please check the documentation of [[HttpRepositoryConnector|HttpRepositoryConnector#how-to-configure-ssl-connection-to-the-repository]] for details of how to setup SSL connection. - [PR-372](https://github.com/Cognifide/knotx/pull/372) - Added cache for compiled Handlebars snippets, you may configure it in Handlebars config, see more in [[Handlebars Knot docs|HandlebarsKnot#how-to-configure]]. - - [PR-374](https://github.com/Cognifide/knotx/pull/374) - Enable keepAlive connection in http client options. This is important fix and we recommend to update your existing configuration of any http client and enable `keepAlive` option. +- [PR-374](https://github.com/Cognifide/knotx/pull/374) - Enable keepAlive connection in http client options. This is important fix and we recommend to update your existing configuration of any http client and enable `keepAlive` option. +- [PR-379](https://github.com/Cognifide/knotx/pull/379) - Added access logging capabilities to the Knotx HTTP Server. Establish standard configuration of logback logger. Check [[Configure Access Log|Server#configure-access-log]] to see how to configure access logs, and [[Logging|Logging]] to see how loggers can be configured to log to console, files for knot.x, access & netty logs. + ## Version 1.1.2 - [PR-335](https://github.com/Cognifide/knotx/pull/335) - Added support for HttpServerOptions on the configuration level. diff --git a/knotx-adapter/knotx-adapter-common/src/test/resources/logback-test.xml b/knotx-adapter/knotx-adapter-common/src/test/resources/logback-test.xml index 9e70e37d..1e67d0c1 100644 --- a/knotx-adapter/knotx-adapter-common/src/test/resources/logback-test.xml +++ b/knotx-adapter/knotx-adapter-common/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-adapter/knotx-adapter-service-http/src/test/resources/logback-test.xml b/knotx-adapter/knotx-adapter-service-http/src/test/resources/logback-test.xml index 9f21cdd9..1e67d0c1 100644 --- a/knotx-adapter/knotx-adapter-service-http/src/test/resources/logback-test.xml +++ b/knotx-adapter/knotx-adapter-service-http/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml index 05c04af8..c49920e1 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/base.xml @@ -20,14 +20,12 @@ Base logback configuration for knot.x --> - - - - - + + + - - + + diff --git a/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml index 8a4f9917..28a59ac6 100644 --- a/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml +++ b/knotx-core/src/main/resources/io/knotx/logging/logback/defaults.xml @@ -21,6 +21,8 @@ Default logback configuration provided for import --> + + diff --git a/knotx-example/knotx-example-action-adapter-http/src/test/resources/logback-test.xml b/knotx-example/knotx-example-action-adapter-http/src/test/resources/logback-test.xml index a4547aa6..1e67d0c1 100644 --- a/knotx-example/knotx-example-action-adapter-http/src/test/resources/logback-test.xml +++ b/knotx-example/knotx-example-action-adapter-http/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-example/knotx-example-app/src/main/resources/logback.xml b/knotx-example/knotx-example-app/src/main/resources/logback.xml index 3f1563b8..427df9f9 100644 --- a/knotx-example/knotx-example-app/src/main/resources/logback.xml +++ b/knotx-example/knotx-example-app/src/main/resources/logback.xml @@ -23,5 +23,4 @@ - diff --git a/knotx-example/knotx-example-app/src/test/resources/logback-test.xml b/knotx-example/knotx-example-app/src/test/resources/logback-test.xml index 542a7b7a..1e67d0c1 100644 --- a/knotx-example/knotx-example-app/src/test/resources/logback-test.xml +++ b/knotx-example/knotx-example-app/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-knot/knotx-knot-action/src/test/resources/logback-test.xml b/knotx-knot/knotx-knot-action/src/test/resources/logback-test.xml index 25b5af64..1e67d0c1 100644 --- a/knotx-knot/knotx-knot-action/src/test/resources/logback-test.xml +++ b/knotx-knot/knotx-knot-action/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-knot/knotx-knot-fragment-splitter/src/test/resources/logback-test.xml b/knotx-knot/knotx-knot-fragment-splitter/src/test/resources/logback-test.xml index 542a7b7a..1e67d0c1 100644 --- a/knotx-knot/knotx-knot-fragment-splitter/src/test/resources/logback-test.xml +++ b/knotx-knot/knotx-knot-fragment-splitter/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-knot/knotx-knot-handlebars/src/test/resources/logback-test.xml b/knotx-knot/knotx-knot-handlebars/src/test/resources/logback-test.xml index d88ffc15..1e67d0c1 100644 --- a/knotx-knot/knotx-knot-handlebars/src/test/resources/logback-test.xml +++ b/knotx-knot/knotx-knot-handlebars/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-knot/knotx-knot-service/src/test/resources/logback-test.xml b/knotx-knot/knotx-knot-service/src/test/resources/logback-test.xml index cbb7c75a..1e67d0c1 100644 --- a/knotx-knot/knotx-knot-service/src/test/resources/logback-test.xml +++ b/knotx-knot/knotx-knot-service/src/test/resources/logback-test.xml @@ -17,22 +17,14 @@ --> + + - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - + + + + + diff --git a/knotx-standalone/src/main/resources/logback.xml b/knotx-standalone/src/main/resources/logback.xml index f94b2e26..fee5b14d 100644 --- a/knotx-standalone/src/main/resources/logback.xml +++ b/knotx-standalone/src/main/resources/logback.xml @@ -17,6 +17,12 @@ --> - + + + + + + + From 247006ccf49e7fa4d6d4868c400319a17fdfe95b Mon Sep 17 00:00:00 2001 From: Maciej Laskowski Date: Thu, 25 Jan 2018 13:18:26 +0100 Subject: [PATCH 09/10] Update DocumentationTemplate.md --- documentation/src/main/DocumentationTemplate.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/src/main/DocumentationTemplate.md b/documentation/src/main/DocumentationTemplate.md index 8aa4dd51..9dc1d1d6 100644 --- a/documentation/src/main/DocumentationTemplate.md +++ b/documentation/src/main/DocumentationTemplate.md @@ -26,6 +26,7 @@ #include "wiki/Mocks.md" #include "wiki/KnotxDeployment.md" #include "wiki/KnotxTuning.md" +#include "wiki/Logging.md" #include "wiki/Dependencies.md" #include "wiki/FAQ.md" #include "wiki/UpgradeNotes.md" From 327e6ac334a8d81a4249358bede99da9db6297c8 Mon Sep 17 00:00:00 2001 From: Marcin Czeczko Date: Thu, 25 Jan 2018 13:27:14 +0100 Subject: [PATCH 10/10] Review fix --- .../java/io/knotx/server/configuration/AccessLogConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java index 12d27982..2a4cf3ca 100644 --- a/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java +++ b/knotx-server/src/main/java/io/knotx/server/configuration/AccessLogConfig.java @@ -24,9 +24,9 @@ public class AccessLogConfig { private static final boolean DEFAULT_LOGGER_IMMEDIATE = false; private static final String DEFAULT_LOGGER_FORMAT = LoggerFormat.DEFAULT.toString(); - private boolean enabled; - private boolean immediate; - private LoggerFormat format; + private final boolean enabled; + private final boolean immediate; + private final LoggerFormat format; public AccessLogConfig(JsonObject config) { enabled = config.getBoolean("enabled", DEFAULT_ENABLED);