I'm using winston v3.2.1
, winston-elasticsearch v0.8.8
and @elastic/elasticsearch v7.6.1
to push log entries for my NodeJS services to an Elastic Search cluster v7.6.2.
My logger is constructed as follows (see https://github.com/vanthome/winston-elasticsearch and https://www.npmjs.com/package/@elastic/elasticsearch):
import { Client } from '@elastic/elasticsearch';
import winston, { Logger } from 'winston';
import { ElasticsearchTransport } from 'winston-elasticsearch';
import { ELASTIC_HOST, ELASTIC_PORT, LOG_LEVEL } from './environment';
...
this.logger = winston.createLogger({
transports: [
new ElasticsearchTransport({
client: new Client({
node: `http://${ELASTIC_HOST}:${ELASTIC_PORT}`
}),
index: 'sector',
level: LOG_LEVEL // Events I log that are 'info' or worse will be transported.
})
]
});
I then log using the logger
reference directly:
this.logger.info(`Kill signal received: ${signal}`);
I can see that my log entries are being pushed to the Elastic Search cluster but the console logs are flooded with debug output from the elasticsearch
and winston:elasticsearch
loggers. I think they belong to the Elastic Node client and Elasticsearch Transport implementations.
2020-05-12T22:10:10.114Z elasticsearch Nothing to resurrect
...
2020-05-12T22:10:10.116Z winston:elasticsearch starting bulk writer
...
2020-05-12T22:10:18.122Z winston:elasticsearch nothing to flush
2020-05-12T22:10:20.123Z winston:elasticsearch tick
2020-05-12T22:10:20.123Z winston:elasticsearch nothing to flush
My services run inside Docker containers and I don't want the Docker logs to flood with debug noise. I tried to set the transport levels to error
and even removing the Console
transport completely but the debug noise persists. I tried the following to suppress the console output without much luck:
winston.level = 'error';
winston.transports.Console.level = 'error';
winston.transports.Console.silent = true;
this.logger.remove(winston.transports.Console);
winston.remove(winston.transports.Console);
I found a couple of threads on the subject but no luck:
It's almost like the client and transporter is using a separate logging mechanism.
Any suggestions?