logging #1507
respondsid
started this conversation in
Ideas
logging
#1507
Replies: 1 comment
-
Hello @respondsid Logger allow adding data for the entire logs by using logger.context method: import {$log} from "@tsed/common";
$log.context.set("spanIds", "uuid"); But if your needs is to add data for each request, you have to override PlatformLogMiddleware. @OverrideProvider(PlatformLogMiddleware)
class CustomLogMiddleware extends PlatformLogMiddleware {
protected requestToObject(ctx: Context): any {
const {request} = ctx;
return {
...super.requestToObject(ctx),
// add your props
};
}
} See you |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
All microservices will need an ability to add b3 traceid and span ids in every log line they emit, it would be nice if this context data can be built and passed around so that every developer dont need to take care of putting it in every log line
So in effect, How can I create a custom log context (similar to MDC in SLF4J in java) so that every log . I tried to override reqIDBuilder but that didnt help much as it is only good for one field called reqID, it would be ideal if this function can return a map of values that can direclt go in as object in context logger
Beta Was this translation helpful? Give feedback.
All reactions