Best practice: Using Winston vs. native Elasticsearch client for logging?

Hello everyone!

Good morning, I'm new to Elasticsearch and still learning the basics.
I have a question — I’ve been reading that maybe the best way to send logs to Elasticsearch is by using the native Elasticsearch client methods, rather than relying on external libraries like Winston or winston-elasticsearch.

Based on your experience, would you recommend using Winston for this purpose, or is it better to interact directly with Elasticsearch through its native client methods?

Thanks in advance for your help and advice!

Hello Guido,

Welcome to this forum! :partying_face:

I have no experience with winston in particular, but I do recommend to use a standard logging facade instead of directly interacting the the Elasticsearch Client:

  • it is easier to switch to another backend when required
  • while the Elasticsearch Client API is not hard, it is not focused on the logging usecase => a logging framework is easier to use
  • you can use [libraries]( ECS Logging with Winston | ECS Logging Node.js ) from Elastic to format your logs correctly

Best regards

Wolfram