Repository navigation
NIFI-16572 Enable per Process Group logging in MiNiFi Java - #11912
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this addition @Vinz2168.
The approach follows the implementation in the main NiFi project, but it raises a question about the value of the feature for MiNiFi.
The general design focus of MiNiFi is a smaller footprint, and more focused flow design. This raises the question about the necessity of having more than one application log, and breaking it out at the Process Group level.
Can you provide some additional details around the proposed use case?
As the Jira issue describes, it is possible to do this with manual configuration, which is not as convenient, but this raises the question about the applicability of per-process-group logging as a general default for MiNiFi.
|
Thanks for the review @exceptionfactory, that's a fair point, so let me clarify the scope of the change and the use case. What the change actually involves The PR does not touch any MiNiFi code. It only:
The framework side is already present in MiNiFi today: Footprint / default behavior I agree that per-PG logging shouldn't be a default for MiNiFi, so I've added a commit to the PR that makes it opt-in:
With the block commented out, logback never instantiates the appender and the class is never loaded, so the runtime behavior and the processing overhead are exactly the same as today. Users who need the feature uncomment one block, and nothing has to be copied into the installation. For reference, with the appender enabled (logback 1.6.6, 1M INFO events to file) the overhead I measured is about 1–1.5%, dominated by file I/O. Use case The concrete need is traceability of the processing activity of a specific flow. The flow uses Today the only option is to increase the retention of With per-PG logging, the messages of that Process Group are also written to a dedicated It also helps with troubleshooting on a running agent: when several Process Groups are active, isolating the messages of the one under investigation from In that sense the feature actually helps keep the overall footprint smaller than the alternative. Side note While testing I found that Let me know if the opt-in approach works for you. |
|
Thanks for the substantive reply @Vinz2168, that provides some helpful background. The opt-in strategy seems like the best one. Although the commented XML is used in some other configurations, I think it is best to leave it out of the default configuration. With that approach, the JAR can be added to the assembly, but would then require customization of the logback.xml to enable. How does that sound? |
|
Thanks @exceptionfactory, that sounds good. I removed the commented configuration from the default |
- Added nifi-per-process-group-logging to minifi-assembly and to the lib directory of both assembly descriptors - Added DEDICATED_LOGGING SiftingAppender with NifiDiscriminator to the default MiNiFi logback.xml, writing to minifi-app-<suffix>.log with the same rolling limits as APP_FILE Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Commented out the DEDICATED_LOGGING appender and its appender-ref so the default logging behavior and overhead are unchanged - Documented how to enable it and that its rolling policy can be tuned independently from APP_FILE Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Guide Remove the commented DEDICATED_LOGGING appender from the default logback.xml and describe how to enable the feature in the MiNiFi System Administrator's Guide instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Now that #11940 is merged, I rebased onto |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for working through the feedback @Vinz2168, the latest approach with the documented example looks good!
Summary
NIFI-16572
MiNiFi Java already contains the framework side of per Process Group logging (NIFI-3065):
StandardProcessGroupkeeps thelogFileSuffixfrom the flow andStandardComponentLogattaches it as a key/value pair to every component log event. The distribution, however, does not ship the routing pieces, so alogFileSuffixset inflow.jsoncurrently has no effect.This PR:
nifi-per-process-group-logging(containingNifiDiscriminator) tominifi-assemblyand includes it inlib/through bothdependencies.xmlanddependencies-windows-service.xml. The bootstrap classpath already includeslib/*on bothminifi.shand the Windows scripts, so the bootstrap can also resolve the discriminator when it reads the sharedlogback.xml;DEDICATED_LOGGINGSiftingAppenderto the default MiNiFiconf/logback.xml, referenced by<root>. Files are named${app.file.name}-<suffix>.${app.file.extension}(by defaultminifi-app-<suffix>.log) and use the same rolling limits asAPP_FILE(10MB / 10 files / 100MB, gzip).As in NiFi, only messages emitted through the component
getLogger()are routed; events without a suffix are ignored by the discriminator.Manual verification on a built assembly: a flow with a child Process Group with
"logFileSuffix": "foo"(GenerateFlowFile -> LogMessage) and a control GenerateFlowFile -> LogMessage in the root group.logs/minifi-app-foo.logcontained only the child group messages,logs/minifi-app.logcontained both, and no logback configuration errors were reported by bootstrap or runtime.Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation
🤖 Generated with Claude Code