aws / aws/aws-lambda-java-libs
Pass Lambda RequestID to SLF4J MDC as well
- 主要语言
- Java
- 星标
- 548
- 派生
- 241
- 平均合并
- 2 天 5 分钟
- 30 天内合并 PR
- 11
描述
https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/EventHandlerLoader.java#L888
Here, code checks for log4j 1/2 MDC classes to set the `AWSRequestId` property so it can be used in the logs.
New Java v2 SDK comes with `slf4j-api` which is heavily used as a logging face for many loggers, including log4j 1/2 but also Logback etc.
Addding a call for `org.slf4j.MDC.put` will help passing the requestID to slf4j context so any implementation can be used freely. Since package size is important, comparing ~2MB size of Log4j2, user can choose any logging implementation using slf4j as facade.
Method name a little misleading, `LambdaRuntimeInternal.setUseLog4jAppender` but this can be ignored I believe or changed as `setUseLoggingAppender` or adding the ability to pass the class name to call the `put` method on, whichever easier/logical.
贡献指南
评估
这个 Issue 还没有评估数据。