观察logstash控制台输出:
{ "@timestamp" => 2021-04-28T15:40:43.182Z, "level" => "DEBUG", "port" => 57778, "thread_name" => "http-nio-8080-exec-1", "level_value" => 10000, "@version" => "1", "host" => "127.0.0.1", "logger_name" => "com.bart.elk.ApiTests", "message" => "[debug] IP=[127.0.0.1] send request URI = [/api/log]" } { "@timestamp" => 2021-04-28T15:40:43.182Z, "level" => "INFO", "port" => 57778, "thread_name" => "http-nio-8080-exec-1", "level_value" => 20000, "@version" => "1", "host" => "127.0.0.1", "logger_name" => "com.bart.elk.ApiTests", "message" => "[info] IP=[127.0.0.1] send request URI = [/api/log]" } { "@timestamp" => 2021-04-28T15:40:43.183Z, "level" => "WARN", "port" => 57778, "thread_name" => "http-nio-8080-exec-1", "level_value" => 30000, "@version" => "1", "host" => "127.0.0.1", "logger_name" => "com.bart.elk.ApiTests", "message" => "[warn] IP=[127.0.0.1] send request URI = [/api/log]" } { "@timestamp" => 2021-04-28T15:40:43.183Z, "level" => "ERROR", "port" => 57778, "thread_name" => "http-nio-8080-exec-1", "level_value" => 40000, "@version" => "1", "host" => "127.0.0.1", "logger_name" => "com.bart.elk.ApiTests", "message" => "[error] IP=[127.0.0.1] send request URI = [/api/log]" }说明运行成功!
参考说明:
logstash-logback-encoder