LoggerEtsBackend (logger_ets_backend v0.1.0) View Source
A simple Logger
backend which writes log entries to an ETS table.
It does not create or manage the table for you; you must do this
external to the logging app.
LoggerEtsBackend
borrows heavily from
[LoggerFileBackend
][logger_file_backend], and therefore acts much
the same way.
Rationale
The primary use-case for this backend is not for persistent logs,
but for temporary logs that may need to be inspected at run-time by
the system itself. By pushing log messages to an ETS table, data can
be quickly searched using match_spec
s based on message contents or
the metadata stored along with the entry.
Configuration
LoggerEtsBackend
is a custom backend for the elixir :logger
application. This backend can only log to a single ETS table, so there
must be one :logger
backend configured for each log file we
need. Each backend has a name like {LoggerEtsBackend, id}
, where
id
is any elixir term (usually an atom).
Note: tables use for logging are recommented to be configured with
the :ordered_set
and :public
options.
Configuration Example
config :logger,
backends: [{LoggerEtsBackend, :inspection_log}]
# configuration for the {LoggerEtsBackend, :critical_log} backend
config :logger, :critical_log,
table: :critical_table,
level: :error
Usage
LoggerEtsBackend
supports the following configuration values:
table
- the table name to push log tuples tolevel
- the logging level for the backendmetadata
- the metadata to includemetadata_filter
- metadata terms which must be present in order to log
Note: It is recommended that metadata_filter
is set for this
backend, to ensure only a small subset of log entries are captured.
Link to this section Summary
Functions
Callback implementation for :gen_event.handle_call/2
.
Callback implementation for :gen_event.handle_event/2
.
Callback implementation for :gen_event.handle_info/2
.
Callback implementation for :gen_event.init/1
.
Link to this section Functions
Callback implementation for :gen_event.handle_call/2
.
Callback implementation for :gen_event.handle_event/2
.
Callback implementation for :gen_event.handle_info/2
.
Callback implementation for :gen_event.init/1
.