Hi Nagesh,

Thanks for the feedback.

> I am not clear how CLS (or, TLS in Java applications) is key to logging. In other words, what could be a logging solution without CLS?

You can simply pass req or any other context object into calls to all of your nested modules, e.g. controllers and services. In that case, each time when you need to log something, you can include fields from the context objects into the log message. The post has an example (see this gist).

> Also, when the service receives 100s of requests per second, the log is going to interspersed with different requests completing at different times. A log consumer (e.g. ELK, Splunk, etc.) is the best way to sift through all those logs.

ELK or any other log collector service doesn’t contradict with CLS-based request id logging. If you try to analyze your collected logs, you still need to filter out all logs that belong to the same HTTP request. Without having request ids in your logs, you’ll get a mess of interleaved messages when your application handles concurrent HTTP requests. And that’s exactly the purpose of request id logging & tracing.



Distributed systems gazer. Node.js contributor. Occasional tech blogger and speaker.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store