@sorrir/sorrir-logging
v2.1.0
Published
Logging repository for SORRIR projects.
Downloads
7
Keywords
Readme
sorrir-logging
Logging tailormade for sorrir
Specifying the logging target
A HowTo log to ES can be found here.
If NODE_ENV
is equal to 'production'
, we log to stdout.
Otherwise, we check whether the environment variables SORRIR_ES_URL
, SORRIR_ES_USER
and SORRIR_ES_PASSWORD
are set.
If one is not, we log to stdout.
Otherwise we log to the Elasticsearch instance specified via these environment variables.
The target index that is logged to can be configured via environment variables as well.
The variable SORRIR_ES_INDEX
can be used to log to a specific index.
The variable SORRIR_ES_INDEX_PREFIX
can be used to log to a date-dependent index (e.g. setting SORRIR_ES_INDEX_PREFIX
to "hello" will make the logger log to the index hello-$timestamp_day
).
If both are specified, SORRIR_ES_INDEX_PREFIX
is disregarded.
If none are specified, the logger behaves as if SORRIR_ES_INDEX_PREFIX
was set to "filebeat-debug".
For easy organisation, there is a possibility to add an additional key-value pair to logs when outputting to Elasticsearch.
Setting the environment variable SORRIR_ES_DEBUG
to your_value
will cause the logs to possess the key-value pair fields.metadata.context.debug = your_value
.