Skip to content

Commit

Permalink
feat(LogbookConfig): use logbook's json formatter as sink
Browse files Browse the repository at this point in the history
Took 41 seconds
  • Loading branch information
vianneynara committed Dec 8, 2024
1 parent 4234510 commit b012ef4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/dev/kons/kuenyawz/configurations/LogbookConfig.java
Original file line number Diff line number Diff line change
@@ -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.
* <br><br>
* <a href="https://www.udemy.com/course/spring-framework-6-beginner-to-guru/learn/lecture/44051012">
* <b>Udemy Reference</b></a>
*/
@Configuration
public class LogbookConfig {

@Bean
public Sink logbookLogStash() {
HttpLogFormatter formatter = new JsonHttpLogFormatter();
LogstashLogbackSink sink = new LogstashLogbackSink(formatter);
return sink;
}
}

0 comments on commit b012ef4

Please sign in to comment.