IMPORTANT: elasticsearch.js has been replaced by the new Elasticsearch JavaScript client. We strongly advise you to migrate to the new client. To learn more, see the migration guide.
Using the default loggers
editUsing the default loggers
editBy default, the client creates a "warning"
level, Console or Stdio logger. To change this, specify the client’s log:
config value to either an array of logger config’s, a single logger config, a log level, an array of log levels, or a constructor for your own logger. That’s a lot of options, so here is an example of each.
Change the logging level to trace, so we get every log message.
var client = new elasticsearch.Client({ log: 'trace' });
Change the logging level, only listen for error and trace messages.
var client = new elasticsearch.Client({ log: ['error', 'trace'] });
Log every message to a file.
var client = new elasticsearch.Client({ log: { type: 'file', level: 'trace', path: '/var/log/elasticsearch.log' } });
Log everything to a file and errors to a socket.
var client = new elasticsearch.Client({ log: [ { type: 'stream', level: 'error', // config option specific to stream type loggers stream: mySocket }, { type: 'file', level: 'trace', // config options specific to file type loggers path: '/var/log/elasticsearch.log' } ] });
Logger Types
edit
|
The default logger for in Node, writes log messages for "info", "debug", and "trace" to stdout and "error" and "warning" to stderr. Options:
|
|
Append the log messages to a file. Options:
|
|
Logs in a format that can be executed with bash, where everything is commented except the trace commands which are formatted as curl calls. By default all of the urls are rewritten to protect production systems and to making the scripts easier to reuse/send to other people. In order to control the urls written specify the curlHost and curlPort configs. Options:
|
|
Send log messages to a WriteableStream Options:
|
|
Default logger for the browser build, logs to the console when one exists. |