1, Logstash plug-in configuration
Logstash under Config folder to add the contents of the test.conf file:
input{ TCP { = = "Server " = "0.0.0.0 " = 4567 = > json_lines }}output{ elasticsearch{ hosts=>["127.0.0.1:9200"] = > "user-%{+yyyy. MM.DD} " } = Rubydebug}}
Start Logstash:./logstash-f. /config/test.conf exposed port 4567 accept Log
2, Spring boot configuration Some file send log can
1) Maven Dependency:
<dependency> <groupId>net.logstash.logback</groupId> <artifactId> logstash-logback-encoder</artifactid> <version>5.1</version> </dependency>
2) Add logback-spring.xml under Resources just change the IP address below.
<?xml version= "1.0" encoding= "UTF-8"?><configuration> <include resource= "org/springframework/ Boot/logging/logback/base.xml "/> class=" Net.logstash.logback.appender.LogstashTcpSocketAppender "> <destination>172.31.226.157:4567</ Destination>//logstash IP and exposed ports, which I now understand is to send the log through this address past class= " Net.logstash.logback.encoder.LogstashEncoder "/> </appender> <root level=" INFO "> < Appender-ref ref= "LOGSTASH"/> <appender-ref ref= "CONSOLE"/> </root></configuration >
3) YML Configuration
logging: config:classpath:logback-spring.xml
Finished, so start Logstash restart Springboot, springboot log can send past, after Elasticsearch collection, Kibana graphical interface display not to repeat
Spring boot integrated Logstash log