安装教程,我的配置如下。也关闭了4560的端口防火墙
然后配置eclipse项目的log4j的配置文件,如下
最后看了下logstash居然纹丝不动,如下:
查看了一下head插件里面,也没存在输出的索引,不知道什么问题。
# For detail structure of this file
# Set: https://www.elastic.co/guide/e ... .html
input {
# For detail config for log4j as input,
# See: https://www.elastic.co/guide/e ... .html
log4j {
mode => "server"
type =>"log4j-json"
host =>"127.0.0.1"
port => 4560
}
}
filter {
#Only matched data are send to output.
}
output {
# For detail config for elasticsearch as output,
# See: https://www.elastic.co/guide/e ... .html
elasticsearch {
hosts => "127.0.0.1:9200" #ElasticSearch host, can be array.
index => "log4j-%{+YYYY.MM.dd}"
document_type => "log4j_type" #The index to write data to, can be any string.
}
}
启动该配置的logstash然后配置eclipse项目的log4j的配置文件,如下
log4j.rootLogger=INFO,console
# for package com.demo.elk, log would be sent to socket appender.
log4j.logger.com.demo.elk=DEBUG, socket
# appender console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%-5p] [%l] %m%n
log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.File=mybatis.log
log4j.appender.File.MaxFileSize=10MB
log4j.appender.File.Threshold=ALL
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n
# appender socket
log4j.appender.socket=org.apache.log4j.net.SocketAppender
log4j.appender.socket.Port=4560
log4j.appender.socket.RemoteHost=192.168.233.132
log4j.appender.socket.layout=org.apache.log4j.PatternLayout
log4j.appender.socket.layout.ConversionPattern=%d [%-5p] [%l] %m%n
log4j.appender.socket.ReconnectionDelay=10000
启动方法,打印日志最后看了下logstash居然纹丝不动,如下:
查看了一下head插件里面,也没存在输出的索引,不知道什么问题。
2 个回复
wanglifeng
赞同来自: xiaoke
第二:output为ES,因此控制台不打印内容是正常的,你需要到ES里看看
tiantian666
赞同来自: