下载
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