From a2f8c0169a62693516b2a3fe53e5c53f3a00a114 Mon Sep 17 00:00:00 2001 From: Pankaj Agrawal Date: Sat, 20 Feb 2021 18:37:27 +0100 Subject: [PATCH] docs: ability to override object mapper used for logging event --- docs/content/core/logging.mdx | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/content/core/logging.mdx b/docs/content/core/logging.mdx index 6d6591f9d..ae355c605 100644 --- a/docs/content/core/logging.mdx +++ b/docs/content/core/logging.mdx @@ -100,6 +100,7 @@ public class App implements RequestHandler This is disabled by default to prevent sensitive info being logged. @@ -165,6 +166,42 @@ public class App implements RequestHandler { + + Logger log = LogManager.getLogger(); + + // highlight-start + static { + ObjectMapper objectMapper = new ObjectMapper(); + LoggingUtils.defaultObjectMapper(objectMapper); + } + // highlight-end + + @Logging(logEvent = true) + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) { + ... + } +} +``` + ## Sampling debug logs You can dynamically set a percentage of your logs to **DEBUG** level via env var `POWERTOOLS_LOGGER_SAMPLE_RATE` or