Spring Boot Tutorial (13) Integration Elk (2)

Source: Internet
Author: User
Tags kibana spring boot tutorial log4j

Configuring, starting Kibana

To Kibana's installation directory:

  

The default configuration is sufficient.

Visit localhost:5601, Web page display:

Proof of successful start-up.

Create a Springboot Project

The starting dependency is as follows:

<dependencies> <dependency> <groupId>org.springframework.boot</groupId>                     <artifactId>spring-boot-starter</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactid>spring-bo ot-starter-logging</artifactid> </exclusion> </exclusions> </depende ncy> <dependency> <groupId>org.springframework.boot</groupId> <artifa Ctid>spring-boot-starter-log4j</artifactid> <version>1.3.8.RELEASE</version> </d Ependency> <dependency> <groupId>org.springframework.boot</groupId> < Artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependenc Y> </dependenciEs> 

  

log4j configuration,/src/resources/log4j.properties as follows:

log4j.rootlogger=info,console# for package Com.demo.elk, log would is sent to socket appender.log4j.logger.com.forezp= DEBUG, socket# Appender socketlog4j.appender.socket=org.apache.log4j.net.socketappenderlog4j.appender.socket.port =4560log4j.appender.socket.remotehost=localhostlog4j.appender.socket.layout= org.apache.log4j.patternlayoutlog4j.appender.socket.layout.conversionpattern=%d [%-5p] [%l]%m% nlog4j.appender.socket.reconnectiondelay=10000# Appender consolelog4j.appender.console= org.apache.log4j.consoleappenderlog4j.appender.console.target=system.outlog4j.appender.console.layout= org.apache.log4j.patternlayoutlog4j.appender.console.layout.conversionpattern=%d [%-5p] [%l]%m%n

  

 

Print Log test:

@RunWith (springrunner.class) @SpringBootTestpublic class Springbootelkapplicationtests {    @Test public    Void Contextloads () {    }    private Logger Logger = Logger.getlogger (GetClass ());    @Test public    void Test () throws Exception {for        (int i=0;i<100;i++) {            logger.info ("Output info  ");            Logger.debug ("Output debug+skkkw buzz kw");            Logger.error ("Output error  buzz Me");}}}    

  

SOURCE Source

Spring Boot Tutorial (13) Integration Elk (2)

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.