logger_logstash_backend
1.0.0
Elixir Logger 的后端,将日志发送到 Logstash UDP 输入。
input {
udp {
codec => json
port => 10001
queue_size => 10000
workers => 10
type => default_log_type
}
}
output {
stdout {}
elasticsearch {
protocol => http
}
}
要在 Mix 项目中使用它,首先将其添加为依赖项:
def deps do
[ { :logger_logstash_backend , "~> 3.0.0" } ]
end
然后运行 mix deps.get 来安装它。
添加 logger 和 tzdata 作为应用程序:
def application do
[ applications: [ :logger , :timex ] ]
end
Logger . add_backend { LoggerLogstashBackend , :debug }
Logger . configure { LoggerLogstashBackend , :debug } ,
host: "127.0.0.1" ,
port: 10001 ,
level: :debug ,
metadata: ...
config :logger ,
backends: [ { LoggerLogstashBackend , :error_log } , :console ]
config :logger , :error_log ,
host: "some.host.com" ,
port: 10001 ,
level: :error ,
type: "my_type_of_app_or_node" ,
metadata: [
extra_fields: "go here"
]