I'm using winston-elasticsearch on an express server, I just wrote the same code as in the documentation
var winston = require('winston');
var Elasticsearch = require('winston-elasticsearch');
var esTransportOpts = {
level: 'info'
};
var logger = winston.createLogger({
transports: [
new Elasticsearch(esTransportOpts)
]
});
when i run the server, I get this error:
TypeError: Elasticsearch is not a constructor
I have installed the lates versions "winston": "^3.2.1" and "winston-elasticsearch": "^0.8.8"
@asma's suggestion, downgrade to 0.7.x, did indeed fix this error for me. However, that left me stuck at an outdated version, getting a different error that is fixed in the latest version.
The issue mentioned by @joe is closed now. It explains that everyone's gotten used to the breaking change by adjusting their syntax. However, the README still has the old syntax.
I was able to get the latest version (0.8.8) working by adjusting the example as follows:
var winston = require('winston');
var winstonElasticSearch = require('winston-elasticsearch');
var esTransportOpts = {
level: 'info'
};
var logger = winston.createLogger({
transports: [
new winstonElasticSearch.ElasticsearchTransport(esTransportOpts)
]
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With