diff --git a/src/main/java/dev/kons/kuenyawz/configurations/LogbookConfig.java b/src/main/java/dev/kons/kuenyawz/configurations/LogbookConfig.java new file mode 100644 index 00000000..4467774c --- /dev/null +++ b/src/main/java/dev/kons/kuenyawz/configurations/LogbookConfig.java @@ -0,0 +1,27 @@ +package dev.kons.kuenyawz.configurations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.zalando.logbook.HttpLogFormatter; +import org.zalando.logbook.Sink; +import org.zalando.logbook.json.JsonHttpLogFormatter; +import org.zalando.logbook.logstash.LogstashLogbackSink; + +/** + * Configures the logstash to properly format the logbook logs. + * Without this, the JSON logs will escape the double quotes and unable + * to be parsed. + *

+ * + * Udemy Reference + */ +@Configuration +public class LogbookConfig { + + @Bean + public Sink logbookLogStash() { + HttpLogFormatter formatter = new JsonHttpLogFormatter(); + LogstashLogbackSink sink = new LogstashLogbackSink(formatter); + return sink; + } +}