log4js-node / log4js-node/log4js-node

any MDC so we do not have to pass a logger around?

Open
#1,431 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.8k
Forks
752
PR merge metrics
No merged PRs in 30d

Description

Is there any request context? In java, it was ThreadLocal until async programming...then Twitter invented Context.scala and Promise.scala so MDC in logback could be swapped.

Best with example.

Filter has MDC.put("requestId", generateUniqueReqId());

in the plain old typescript code without passing loggers around all the place(bad smell if we have to pass our logger all around) ->

```
class SomeBizClass {
private _logger = createLogger();
public someMethod(request: FetchPhotosRequest): FetchPhotosResponse {
_logger.info("My log here"");
return ...
}
}
```

In this case, the output is msg="My log here" requestId="xxxsomeReqIdxxx"

Is this possible? This was an amazing thing about logback and log4j so in GCP, AWS, you simply filtered on requestId and developers never had to remember to
1. pass a logger around
2. type in requestId in every single log statement(nor pass requestId around).

It made things 1. extremely efficient and 2. error-prone. (no one every made any errors forgetting to pass a logger or requestID to log it).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or implementation entry point is named in the issue. Start by locating the logger creation and request-handling paths, then review how asynchronous request context could be represented without passing loggers or request IDs; done means a documented feasibility decision and a working example if the project supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.