quarkiverse / quarkus-logging-json

Quarkus logging extension outputting the logging in json.
Apache License 2.0
62 stars 29 forks source link

> Null MDC Data when Accessing in public void writeTo(final JsonGenerator generator, final ExtLogRecord event) #254

Closed iqnev closed 1 year ago

iqnev commented 1 year ago

Hi,

in my custom extension I'm using the MDC (Mapped Diagnostic Context) to store data for logging purposes. I have successfully put data in the MDC within a class, but when I try to access the same data in another class(in the given extension), it is returning null.

This class implemets JsonProvider

@RequiredArgsConstructor
@ApplicationScoped
public class JsonLogProvider implements JsonProvider {

  @Override
  public void writeTo(final JsonGenerator generator, final ExtLogRecord event) throws IOException {

    event.getMdc("myField"); //the value is NULL

  }

I have verified that the thread context is different when attempting to access the MDC data in the second class.

iqnev commented 1 year ago

The issue is resolved