Vincenzo Lombardo created NIFI-16572:
----------------------------------------

             Summary: Enable per Process Group logging in MiNiFi Java
                 Key: NIFI-16572
                 URL: https://issues.apache.org/jira/browse/NIFI-16572
             Project: Apache NiFi
          Issue Type: Improvement
          Components: MiNiFi
            Reporter: Vincenzo Lombardo


h2. Description

NIFI-3065 (fixed in 1.23.0 / 2.0.0-M1) introduced per Process Group logging. A 
Process Group can set a {_}Log File Suffix{_}, and the logs of every component 
inside it are also written to a dedicated {{nifi-app-<suffix>.log}} file.

The framework side of this feature already runs in MiNiFi Java:
 * {{StandardProcessGroup}} keeps the {{logFileSuffix}} from the flow 
definition.
 * {{StandardComponentLog}} adds the {{logFileSuffix}} key/value pair to every 
logging event a component emits.

MiNiFi does not ship the two remaining pieces, so the suffix set in 
{{flow.json}} has no effect:
 # The {{nifi-per-process-group-logging}} jar, which holds 
{{{}org.apache.nifi.logging.NifiDiscriminator{}}}, is not in the MiNiFi 
assembly. NiFi puts it in {{lib/}} 
({{{}nifi-assembly/src/main/assembly/core.xml{}}}); MiNiFi's 
{{dependencies.xml}} does not.
 # The MiNiFi default {{conf/logback.xml}} has no {{DEDICATED_LOGGING}} 
{{{}SiftingAppender{}}}, and nothing references one from the root logger.

Users can work around this today by copying the jar into {{lib/}} and editing 
{{logback.xml}} by hand. Upgrades undo that work, and the jar version has to 
match the framework version.
h2. Proposed change
 * {{{}minifi/minifi-assembly/pom.xml{}}}: add the 
{{org.apache.nifi:nifi-per-process-group-logging}} dependency.
 * {{minifi/minifi-assembly/src/main/assembly/dependencies.xml}} and 
{{{}dependencies-windows-service.xml{}}}: include the artifact in {{{}lib/{}}}.
 * {{{}minifi-resources/src/main/resources/conf/logback.xml{}}}: add the 
{{DEDICATED_LOGGING}} {{SiftingAppender}} with {{{}NifiDiscriminator{}}}, and 
reference it from {{{}<root>{}}}. This matches the NiFi default configuration. 
The appender uses the MiNiFi bootstrap log properties, so the files are named 
{{minifi-app-<suffix>.log}} by default. Rolling limits match the existing 
MiNiFi {{APP_FILE}} appender (10MB / 10 files / 100MB).

h2. Expected behaviour

A MiNiFi flow whose Process Group has {{"logFileSuffix": "foo"}} writes the 
logs of that group's components to {{{}logs/minifi-app-foo.log{}}}, in addition 
to {{{}minifi-app.log{}}}. This is the same behaviour as NiFi.
h2. Notes

Only messages logged through the component's {{ComponentLog}} 
({{{}getLogger(){}}}) are routed. Loggers that a component creates directly 
with SLF4J are not routed, which is also the case in NiFi.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to