Andrey Pechkurov
1 min readNov 6, 2019

--

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.

--

--

Andrey Pechkurov
Andrey Pechkurov

Written by Andrey Pechkurov

Core database engineer at QuestDB. Distributed systems gazer. Node.js contributor. Occasional tech blogger and speaker.

No responses yet