ElasticsearchLoggerBackend
Send logs in batches via the elasticsearch bulk index api!
Installation
If available in Hex, the package can be installed as:
-
Add
elasticsearch_logger_backendto your list of dependencies inmix.exs:
```elixir
def deps do
[{:elasticsearch_logger_backend, "~> 0.1.0"}]
end
```-
Ensure
elasticsearch_logger_backendis started before your application:
```elixir
def application do
[applications: [:elasticsearch_logger_backend]]
end
```Usage
Application config:
config :logger,
backends: [{ElasticsearchLoggerBackend, :es_log}]
config :logger, :es_log, [
level: :info,
index_format: "index-{YYYY}.{0M}.{0D}",
elasticsearch_uri: "http://elasticsearch:9200/"
]Runtime config:
Logger.add_backend({ElasticsearchLoggerBackend, :es_log})
Logger.configure_backend({ElasticsearchLoggerBackend, :es_log}, [
elasticsearch_uri: "http://elasticsearch:9200/",
index_format: "index-{YYYY}.{0M}.{0D}",
level: :info,
])Config Options
level- The minimum level to be logged by this backend.metadata- The metadata to be included as fields on the event. Defaults to an empty list (no metadata).elasticsearch_uri- Uri of the elasticsearch instance used for logs.type- Type used for log events. Defaults tologeventindex_format- Index used for log events. Can be a Timex format string to include date information, such as"index-{YYYY}.{0M}.{0D}"ship_interval- How often buffered log events are sent to the elasticsearch cluster. Defaults to5_000ms,timezone- Timex timezone used in formatting the@timestampfield. Default to:utc.