I'm using NiFi with a mix of built-in processors and custom processors. I need to be able to append some meta data onto a log message about the processor from which that log message was generated (including from vanilla/default/built-in processors).
The easiest way I can think to do this is to configure MDC for the logger. The problem is, I don't see where you can configure NiFi to use a custom logger in place of its default one.
I do see that NiFi has the ComponentLog
interface which can be implemented, and from that I would have enough contextual information to append meta data to my log message. However, from what I can tell, this is only possible within a custom processor (implement the ComponentLog interface instead of using some 3rd party logger).
Is there some way to do this? Specifically, I need to log (on every log message) things like which processor and any of the variables / attributes available to that processor.
I can do this by modifying the source and re-building it but I'd really prefer not to have to change/rebuild a fork of NiFi just to do this.
Any help is appreciated.
I wound up solving this by modifying the logback.xml pattern. There are built in handlers for non-default things and to interface with MDC.
https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html has a good list, specifically X
which'll let you get to things from MDC.