aws / aws/aws-lambda-java-libs

Pass Lambda RequestID to SLF4J MDC as well

Ouverte
#265 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Java
Étoiles
548
Forks
241
Merge moyen
2 j 5 min
PR mergées (30 j)
11

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.