Springboot log4j 集成ELK
ELK组成
Elasticsearch-5.6.5 Java语言开发的搜索引擎,日志分析、搜索
Logstash-5.6.5 日志采集、过滤(解析转换)、储存和输出
Kibana-5.6.5 数据的可视化
ELK下载地址
前提
spring boot 已集成log4j
ELK 安装和配置 Springboot集成ELK日志管理
依赖
<!-- log4j2整合logstash-->
<dependency>
<groupId>biz.paluch.logging</groupId>
<artifactId>logstash-gelf</artifactId>
<version>1.12.0</version>
</dependency>
<!-- log4j2 AsyncLogger 异步缓冲输出-->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
</dependency>
log4j2.yml配置
原配置文件上增加如下配置:
Configuration:
Appenders:
Socket:
name: logstash-tcp
host: 10.1.6.123
port: 4560
protocol: TCP
PatternLayout:
pattern: "%d{yyyy-MM-dd HH:mm:ss.SSS}{black} %highlight{%-5level }[%style{%t}{bright,magenta}] %style{%C{1.}}{cyan}: %msg%n%throwable"
Loggers:
AsyncLogger:
name: com.guodi
level: info
includeLocation: true
appender-ref:
ref: logstash-tcp