title: Separate log file for custom processor
body: <p>NiFi 1.2.0</p>
  
  <p>Need to create a separate log file, say, customprocessor.log besides the app.log file created by NiFi.</p>
  
  <p>I went through some interesting, existing threads like this, however, I am unable to figure out how to make it working in the code.</p>
  
  <p>Following is the existing logback.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration scan="true" scanPeriod="30 seconds"&gt;
      &lt;contextListener&gt;
          &lt;resetJUL&gt;true&lt;/resetJUL&gt;
      &lt;/contextListener&gt;
      &lt;appender name="APP_FILE"&gt;
          &lt;file&gt;/var/log/nifi/nifi-app.log&lt;/file&gt;
          &lt;rollingPolicy&gt;
              &lt;!--
                                 For daily rollover, use 'app_%d.log'.
                For hourly rollover, use 'app_%d{yyyy-MM-dd_HH}.log'.
                To GZIP rolled files, replace '.log' with '.log.gz'.
                To ZIP rolled files, replace '.log' with '.log.zip'.
              --&gt;
              &lt;fileNamePattern&gt;/var/log/nifi/archive/nifi-app_%d{yyyy-MM-dd_HH}.%i.log&lt;/fileNamePattern&gt;
              &lt;timeBasedFileNamingAndTriggeringPolicy&gt;
                  &lt;maxFileSize&gt;100MB&lt;/maxFileSize&gt;
              &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
              &lt;!-- keep 30 log files worth of history --&gt;
              &lt;maxHistory&gt;3&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%date %level [%thread] %logger{40} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
       &lt;immediateFlush&gt;true&lt;/immediateFlush&gt;
      &lt;/appender&gt;
      &lt;appender name="USER_FILE"&gt;
          &lt;file&gt;/var/log/nifi/nifi-user.log&lt;/file&gt;
          &lt;rollingPolicy&gt;
              &lt;!--
                                 For daily rollover, use 'user_%d.log'.
                For hourly rollover, use 'user_%d{yyyy-MM-dd_HH}.log'.
                To GZIP rolled files, replace '.log' with '.log.gz'.
                To ZIP rolled files, replace '.log' with '.log.zip'.
              --&gt;
              &lt;fileNamePattern&gt;/var/log/nifi/archive/nifi-user_%d.log&lt;/fileNamePattern&gt;
              &lt;!-- keep 30 log files worth of history --&gt;
              &lt;maxHistory&gt;3&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%date %level [%thread] %logger{40} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
      &lt;appender name="BOOTSTRAP_FILE"&gt;
          &lt;file&gt;/var/log/nifi/nifi-bootstrap.log&lt;/file&gt;
          &lt;rollingPolicy&gt;
              &lt;!--
                For daily rollover, use 'user_%d.log'.
                For hourly rollover, use 'user_%d{yyyy-MM-dd_HH}.log'.
                To GZIP rolled files, replace '.log' with '.log.gz'.
                To ZIP rolled files, replace '.log' with '.log.zip'.
              --&gt;
              &lt;fileNamePattern&gt;/var/log/nifi/archive/nifi-bootstrap_%d.log&lt;/fileNamePattern&gt;
              &lt;!-- keep 5 log files worth of history --&gt;
              &lt;maxHistory&gt;5&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%date %level [%thread] %logger{40} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
      &lt;appender name="CONSOLE"&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%date %level [%thread] %logger{40} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
      &lt;!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR --&gt;
      &lt;logger name="org.apache.nifi" level="INFO"/&gt;
      &lt;logger name="org.apache.nifi.processors" level="WARN"/&gt;
      &lt;logger name="org.apache.nifi.processors.standard.LogAttribute" level="INFO"/&gt;
      &lt;logger name="org.apache.nifi.controller.repository.StandardProcessSession" level="WARN" /&gt;
      &lt;logger name="org.apache.zookeeper.ClientCnxn" level="ERROR" /&gt;
      &lt;logger name="org.apache.zookeeper.server.NIOServerCnxn" level="ERROR" /&gt;
      &lt;logger name="org.apache.zookeeper.server.NIOServerCnxnFactory" level="ERROR" /&gt;
      &lt;logger name="org.apache.zookeeper.server.quorum" level="ERROR" /&gt;
      &lt;logger name="org.apache.zookeeper.ZooKeeper" level="ERROR" /&gt;
      &lt;logger name="org.apache.zookeeper.server.PrepRequestProcessor" level="ERROR" /&gt;
      &lt;logger name="org.apache.calcite.runtime.CalciteException" level="OFF" /&gt;
      &lt;logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" /&gt;
      &lt;logger name="org.apache.curator.ConnectionState" level="OFF" /&gt;
      &lt;!-- Logger for managing logging statements for nifi clusters. --&gt;
      &lt;logger name="org.apache.nifi.cluster" level="INFO"/&gt;
      &lt;!-- Logger for logging HTTP requests received by the web server. --&gt;
      &lt;logger name="org.apache.nifi.server.JettyServer" level="INFO"/&gt;
      &lt;!-- Logger for managing logging statements for jetty --&gt;
      &lt;logger name="org.eclipse.jetty" level="INFO"/&gt;
      &lt;!-- Suppress non-error messages due to excessive logging by class or library --&gt;
      &lt;logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/&gt;
      &lt;logger name="com.sun.jersey.spi.spring" level="ERROR"/&gt;
      &lt;logger name="org.springframework" level="ERROR"/&gt;
      &lt;!-- Suppress non-error messages due to known warning about redundant path annotation (NIFI-574) --&gt;
      &lt;logger name="com.sun.jersey.spi.inject.Errors" level="ERROR"/&gt;
      &lt;!--
          Logger for capturing user events. We do not want to propagate these
          log events to the root logger. These messages are only sent to the
          user-log appender.
      --&gt;
      &lt;logger name="org.apache.nifi.web.security" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="USER_FILE"/&gt;
      &lt;/logger&gt;
      &lt;logger name="org.apache.nifi.web.api.config" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="USER_FILE"/&gt;
      &lt;/logger&gt;
      &lt;logger name="org.apache.nifi.authorization" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="USER_FILE"/&gt;
      &lt;/logger&gt;
      &lt;logger name="org.apache.nifi.cluster.authorization" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="USER_FILE"/&gt;
      &lt;/logger&gt;
      &lt;logger name="org.apache.nifi.web.filter.RequestLogger" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="USER_FILE"/&gt;
      &lt;/logger&gt;
      &lt;!--
          Logger for capturing Bootstrap logs and NiFi's standard error and standard out.
      --&gt;
      &lt;logger name="org.apache.nifi.bootstrap" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="BOOTSTRAP_FILE" /&gt;
      &lt;/logger&gt;
      &lt;logger name="org.apache.nifi.bootstrap.Command" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="CONSOLE" /&gt;
          &lt;appender-ref ref="BOOTSTRAP_FILE" /&gt;
      &lt;/logger&gt;
      &lt;!-- Everything written to NiFi's Standard Out will be logged with the logger org.apache.nifi.StdOut at INFO level --&gt;
      &lt;logger name="org.apache.nifi.StdOut" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="BOOTSTRAP_FILE" /&gt;
      &lt;/logger&gt;
      &lt;!-- Everything written to NiFi's Standard Error will be logged with the logger org.apache.nifi.StdErr at ERROR level --&gt;
      &lt;logger name="org.apache.nifi.StdErr" level="ERROR" additivity="false"&gt;
          &lt;appender-ref ref="BOOTSTRAP_FILE" /&gt;
      &lt;/logger&gt;
      &lt;root level="DEBUG"&gt;
          &lt;appender-ref ref="APP_FILE"/&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now, I can add a new appender for the custom log file :</p>
  
  <pre><code>&lt;!-- Start : Separate log file for custom processor --&gt;
  &lt;appender name="CUSTOM_FILE"&gt;
          &lt;file&gt;/var/log/nifi/custom-processor.log&lt;/file&gt;
          &lt;rollingPolicy&gt;
              &lt;!--
                                 For daily rollover, use 'app_%d.log'.
                For hourly rollover, use 'app_%d{yyyy-MM-dd_HH}.log'.
                To GZIP rolled files, replace '.log' with '.log.gz'.
                To ZIP rolled files, replace '.log' with '.log.zip'.
              --&gt;
              &lt;fileNamePattern&gt;/var/log/nifi/archive/custom-processor_%d{yyyy-MM-dd_HH}.%i.log&lt;/fileNamePattern&gt;
              &lt;timeBasedFileNamingAndTriggeringPolicy&gt;
                  &lt;maxFileSize&gt;100MB&lt;/maxFileSize&gt;
              &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
              &lt;!-- keep 30 log files worth of history --&gt;
              &lt;maxHistory&gt;3&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%date %level [%thread] %logger{40} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
       &lt;immediateFlush&gt;true&lt;/immediateFlush&gt;
      &lt;/appender&gt;
  &lt;!-- End : Separate log file for custom processor --&gt;
  
  
  
  &lt;!-- Start : Separate log file for custom processor --&gt;
      &lt;logger name="com.nifi.CustomLog" level="DEBUG" additivity="false"&gt;
          &lt;appender-ref ref="CUSTOM_FILE" /&gt;
      &lt;/logger&gt;
      &lt;!-- End : Separate log file for custom processor --&gt;
  </code></pre>
  
  <p>I have the following questions :</p>
  
  <ol>
  <li>Are the entries that I am adding correct</li>
  <li><p>In the code, I use the following snippet to get the root logger,
  however, I didn't find a method/constructor to get my custom logger
  in the code, how shall I do that ?</p>
  
  <p>import org.apache.nifi.logging.ComponentLog;..final ComponentLog logger = getLogger();logger.debug("...");</p></li>
  </ol>