Using LogstashTCPAppender

The library logstash-logback-encoder provides three types of appenders—UDP, TCP, and async. The TCP appender is most commonly used. What is worth mentioning is that TCP appenders are asynchronous, and all the encoding and communication is delegated to a single thread. In addition to appenders, the library also provides some encoders and layouts to enable you to log in the JSON format. Because Spring Boot includes a Logback library by default, as well as spring-boot-starter-web, we only have to add one dependency to Maven pom.xml:

<dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.11</version></dependency>

The next step is to define the appender with the ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.