aws / aws/aws-lambda-java-libs
Pass Lambda RequestID to SLF4J MDC as well
- Lenguaje dominante
- Java
- Estrellas
- 548
- Forks
- 241
- Merge medio
- 2 d 5 min
- PR fusionados (30 d)
- 11
Descripción
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.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.