Spring Boot Integrated Logstash log

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.