logstash收集java程序日志

一 logstash配置文件

[root@DNS-Server ~]# cat /etc/logstash/conf.d/java.conf
input {
    file {
      path => "/var/log/logstash/logstash-plain.log"
      type => "java-log"
      codec => multiline {
      pattern => "^\[(\d{4}-\d{2}-\d{2})"         #正则匹配行开始
      negate => true
      what => "previous"                          #行首结束
      }
}
}
output {
  elasticsearch {
    hosts => ["192.168.10.10:9200"]
    index => "javalog-xuan-%{+YYYY.MM}"
  }
}

二 验证

 

posted @ 2018-08-09 14:35  闫世成  阅读(1413)  评论(0编辑  收藏  举报