-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LogbookConfig): use logbook's json formatter as sink
Took 41 seconds
- Loading branch information
1 parent
4234510
commit b012ef4
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/dev/kons/kuenyawz/configurations/LogbookConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |