Hi Sudeep. SLF4J Loggers are available throughout the code. Are you trying to log details from inside a processor? Within the framework, there are various implementations of `ComponentLog` [1], and `ProcessorLog` (just a marker interface), which is implemented by `SimpleProcessLogger` [2]. From within a processor which extends `AbstractProcessor` [3], you can call `getLogger()` to return an instance of `ProcessorLog` and then write to it as you would any SLF4J logger instance.
```java String key = "someKey"; String value = "someValue"; final ProcessorLog logger = getLogger(); logger.warn("This is a warning message"); logger.info("This is a message with some interpolation key={}, value={}", new String[]{key, value}); ``` This will result in the output: ``` [pool-2-thread-1] WARN org.apache.nifi.processors.standard.EncryptContent - EncryptContent[id=1c569c19-d37b-4d30-aec7-410b318c360d] This is a warning message [pool-2-thread-1] INFO org.apache.nifi.processors.standard.EncryptContent - EncryptContent[id=1c569c19-d37b-4d30-aec7-410b318c360d] This is a message with some interpolation key=someKey, value=someValue ``` We recommend using SLF4J, but if you have a requirement to use Log4j, you can use an adapter as described here [4]. [1] https://github.com/apache/nifi/blob/3a7ddc6a35f143c1d4a735226fe7467a83d04583/nifi-api/src/main/java/org/apache/nifi/logging/ComponentLog.java [2] https://github.com/apache/nifi/blob/807eb8de6d7054cef1fac91cbf2e2a1eb37d30ed/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/processor/SimpleProcessLogger.java [3] https://github.com/apache/nifi/blob/31fba6b3332978ca2f6a1d693f6053d719fb9daa/nifi-api/src/main/java/org/apache/nifi/processor/AbstractProcessor.java [4] http://www.slf4j.org/legacy.html Andy LoPresto alopresto.apa...@gmail.com PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Feb 10, 2016, at 7:54 PM, sudeep mishra <sudeepshekh...@gmail.com> wrote: > > Hi, > > What is the preferred practice for logging details for NiFi data flow? How > can I use my own logging using log4j to log custom details for NiFi data flow. > > > Thanks & Regards, > > Sudeep
signature.asc
Description: Message signed with OpenPGP using GPGMail