Hi You are welcome to investigate this and see if you can get MDC to work. You need to enable it first in Camel. And then find out how to map that to ECS layout in log4j.
On Thu, May 11, 2023 at 8:59 AM Mikael Koskinen <mijap...@gmail.com> wrote: > Hi, > > I'm wondering if it would be possible to include ExchangeId into log > messages when using Camel Jbang to run integration with JSON Logging? > > The idea is to be able to group the log messages by the exchange. > > Currently the ExchangeId is included in the "message" field when an > error happens: > > "message": "Failed delivery for (MessageId: > 4762099352DD338-0000000000000001 on ExchangeId: > 4762099352DD338-0000000000000001). Exhausted after delivery attempt: 1 > caught: org.apache.camel.http.base.HttpOperationFailedException: HTTP > operation failed invoking https://we > > The JSON logging seems to use EcsLayout: > > { > "@timestamp": "${json:timestamp}", > "log.level": "${json:level}", > "message": "${json:message}", > "process.thread.name": "${json:thread:name}", > "log.logger": "${json:logger:name}", > "labels": "${json:mdc}", > "tags": "${json:ndc}", > "error.type": "${json:exception:className}", > "error.message": "${json:exception:message}", > "error.stack_trace": "${json:exception:stackTrace:text}" > } > > > And I think the mdc (labels) or ndc (tags) could be a suitable place > to hold this information. > > Also the idea is that if my integration contains a Log step: > > - log: > message: Handling stuff ${header.stuffNo} > loggingLevel: DEBUG > > When logged using the JSON Logging this also would contain the > ExchangeId in mdc/ndc. > > What do you think? > > Best regards, > Mikael > -- Claus Ibsen ----------------- @davsclaus Camel in Action 2: https://www.manning.com/ibsen2