Configuré mi aplicación web para usar un MDC de esta manera:
MDC.put("cliente", "TEST");
org.slf4j.MDC.put("cliente2", "TEST2");
Dentro de la clase de inicio para el servicio REST javax.ws.rs.core.Application
import org.jboss.logging.MDC;
@ApplicationPath("/api")
public class ApplicationResource extends Application {
public ApplicationResource(){
MDC.put("cliente", "TEST");
org.slf4j.MDC.put("cliente2", "TEST2");
}
Y el resultado de la aplicacion en el registro fue:
[TEST] [TEST2] 21:18:25,048 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,115 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002205: Adding provider class com.mypackage.providers.ObjectMapperContextResolver from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002200: Adding class resource com.mypackage.PronetResource from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002200: Adding class resource io.swagger.jaxrs.listing.ApiListingResource from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002205: Adding provider class io.swagger.jaxrs.listing.SwaggerSerializers from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002200: Adding class resource com.mypackage.ResourceOne from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002200: Adding class resource com.mypackage.ResourceTwo from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,116 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 29) RESTEASY002205: Adding provider class com.mypackage.mappers.ExceptionMapper from Application class com.mypackage.ApplicationResource$Proxy$_$$_WeldClientProxy
[TEST] [TEST2] 21:18:25,227 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 29) WFLYUT0021: Registered web context: /api/test
[] [] 21:18:25,292 INFO [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0010: Deployed "api-test-web" (runtime-name : "api-test-web.war")
[2018-03-01 09:18:25,311] Artifact api-test-web:war exploded: Artifact is deployed successfully
[2018-03-01 09:18:25,311] Artifact api-test-web:war exploded: Deploy took 13,992 milliseconds
[] [] 21:18:31,004 INFO [com.mypackage.TestApiImpl] (default task-1) Consulting... --> Request: QueryRequest(tipo_documento=CI, documento=5789124)
[] [] 21:18:31,173 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-1) HHH000397: Using ASTQueryTranslatorFactory
[] [] 21:18:31,605 INFO [com.mypackage.TestApiImpl] (default task-1) End consulting --> Response: QueryResponse(datos=[])
[] [] 21:28:44,315 INFO [com.mypackage.TestApiImpl] (default task-2) Consulting... --> Request: QueryRequest(tipo_documento=CI, documento=4199210)
[] [] 21:28:44,332 INFO [com.mypackage.TestApiImpl] (default task-2) End consulting --> Response: QueryResponse(data=[])
¿Por qué el MDC que inicialicé se borra? ¿Es necesario que lo declare en algún otro lugar?