JavaScript client for Sematext Logs
npm install logsene-jsJavaScript client for Sematext Logs.
npm install logsene-js --save
var Logsene = require('logsene-js')
var logger = new Logsene ('LOGS-APP-TOKEN')
logger.log ('info', 'text message', {tags: ['a','b'], customField: 'custom-field'})
- __token__ - Logs App token. Sign up here.
- __type__ - Optional. Default type of your logs - please note you can define Elasticsearch mapping templates in Sematext Logs
- __url__ - Sematext Logs receiver URL (e.g. if you are shipping logs to Sematext Enterprise), defaults to ``'https://logsene-receiver.sematext.com/_bulk'`true
- __storageDirectory__ - Directory where to buffer logs in the case of failure
- __options__:
- __useIndexInBulkUrl__ - If set to 'false' /_bulk will be used /indexName/_bulk otherwise.
- __httpOptions__ - general HTTP/HTTPS options for the request, e.g. SSL key,cert,passphrase,ca,rejectUNauthorized etc.
- __silent__ - If set to , logsene-js will not log debug and errors to stdout. Used for prod envs, but not mandatory. This is false by default.
In general Elasticsearch > 2.3 (including Sematext Logs) does not allow fields with leading underscore or dots in field names. Logsene-js converts such fields names (e.g. removing leading underscores, and replaces dots to underscores). However, a few fields are interpreted for indexing before renaming the fields:
- _type - used as '_type' in the index operation (bulk indexing)
- _id - used as '_id' in the index operation (bulk indexing)
will not buffer logs at all.
- LOGS_BUFFER_ON_APP_LIMIT - default 'true'. HTTP bulk requests are retried until Sematext starts accepting logs again. Please increase your daily limit setting in Logs App settings if you see "403, App limit reached" errors. Setting the value to 'false' will disable disk buffering only for failed http requests '403, Forbidden / App limit reached'. We recommend to keep the default setting 'true' to avoid any loss of logs.
- LOGS_REMOVE_FIELDS - a comma separated list of fields, which should not be logged. For nested objects use a dot notation e.g. 'reques.body,request.size'__Note:__ Previous versions of logsene-js used LOGSENE instead of LOGS prefix for the settings above. Logsene-js is backward compatible to previous environment variable names. However all variable names with the LOGSENE prefix are depracated and might be removed in future relases.
Security
- HTTPS is enabled by default
- Environment variables for Proxy servers:
- For HTTPS endpoints (default): HTTPS_PROXY / https_proxy
`
export HTTPS_PROXY=https://my-ssl-proxy.example
export HTTPS_PROXY=http://my-proxy.example
`
- For HTTP endpoints (e.g. On-Premises): HTTP_PROXY / http_proxy
`
export HTTP_PROXY=http://my-proxy.example
export HTTP_PROXY=https://my-ssl-proxy.example
``- Please check winston-logsene a transport layer for the winston logging framework.
- Please see bunyan-logsene a transport layer for the bunyan logging framework.