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)