看,灰机...

logstash配置log4j控制台无反应

Logstash | 作者 lxwan08 | 发布于2018年06月20日 | 阅读数:2455

安装教程,我的配置如下。也关闭了4560的端口防火墙
# 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
360截图18720119118125115.png

然后配置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
启动方法,打印日志

360截图18250910678596.png

 
最后看了下logstash居然纹丝不动,如下:

360截图18720119118125115.png

 
查看了一下head插件里面,也没存在输出的索引,不知道什么问题。
已邀请:

wanglifeng

赞同来自: xiaoke

第一:logstash只监听127.0.0.1 没有监听192.168.233.132
第二:output为ES,因此控制台不打印内容是正常的,你需要到ES里看看

tiantian666

赞同来自:

大哥,小弟也遇到了这个问题,logstash 输出到控制台没有反应,怎么解决的呢?跪求答案

要回复问题请先登录注册