aws / aws/aws-lambda-java-libs
Pass Lambda RequestID to SLF4J MDC as well
- 主要言語
- Java
- スター
- 548
- フォーク
- 241
- 平均マージ
- 2日 5分
- マージ済み PR(30日)
- 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 はまだ評価されていません。