Logstash安装&springboot应用集成

下载

cd /opt
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.0.0.tar.gz
tar -zxvf logstash-6.0.0.tar.gz

启动Logstash

cd /opt/logstash-6.0.0
nohup bin/logstash -f config/logstash-springboot.yml &

Logstash和logback集成配置

vi /opt/logstash/config/logstash-springboot.yml
input {
    tcp {
        type => "springboot-application"
        port => 18010
        host => "0.0.0.0"
    }
}
output {
    if [type] == "springboot-application" {
        file {
            path => "/opt/logstash/logs/springboot-application-%{+YYYY.MM.dd}.log"
            codec => line { format => "%{message}"}
        }
    } else {
#   elasticsearch {
#       action => "index"
#       hosts => ["192.168.1.10:9200"]
#       index  => "applog"
#   }
#   stdout { codec => rubydebug }    
    }
}

Logstash常用配置
//验证配置是否正确

bin/logstash -f config/logstash-springboot.yml --config.test_and_exit

//重新加载配置文件

bin/logstash -f config/logstash-springboot.yml --config.reload.automatic
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容