Search code examples
javalogginglogbackmdc

Is it possible to disable MDC logging fields in logback for a specific appender/logger?


I need to add an additional logging layer to a project (SpringBoot+LogBack). Currently some fields are added to the MDC to be included in the logs, which is fine.

In the new logging layer, I use a new appender and logger and I need to exclude the MDC fields from these log entries, is that possible?


Solution

  • Found a solution, posting it as an answer to save time for others. It is possible using logback logstash encoder. You simply can add <includeMdc>false</includeMdc> to the appender.