2017-06-22 11 views
0

NiFi 1.2.0NiFiカスタムプロセッサのカスタムログ、2つの場所でのログイン

私はカスタムプロセッサを持っており、同じ専用のログファイルを持っています。したがって、私は名前のアペンダを使用するようにcom.datalake.processors.SQLServerCDCProcessorクラスを設定している「SQLSERVER-CDC」

logback.xmlを以下に示します。

<?xml version="1.0" encoding="UTF-8"?> 
<configuration scan="true" scanPeriod="30 seconds"> 
    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"> 
     <resetJUL>true</resetJUL> 
    </contextListener> 

    <appender name="APP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>/var/log/nifi/nifi-app.log</file> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <!-- 
           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'. 
      --> 
      <fileNamePattern>/var/log/nifi/archive/nifi-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> 
      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> 
       <maxFileSize>100MB</maxFileSize> 
      </timeBasedFileNamingAndTriggeringPolicy> 
      <!-- keep 30 log files worth of history --> 
      <maxHistory>3</maxHistory> 
     </rollingPolicy> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> 
     </encoder> 
    <immediateFlush>true</immediateFlush> 
    </appender> 

    <appender name="USER_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>/var/log/nifi/nifi-user.log</file> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <!-- 
           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'. 
      --> 
      <fileNamePattern>/var/log/nifi/archive/nifi-user_%d.log</fileNamePattern> 
      <!-- keep 30 log files worth of history --> 
      <maxHistory>3</maxHistory> 
     </rollingPolicy> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> 
     </encoder> 
    </appender> 

    <appender name="BOOTSTRAP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>/var/log/nifi/nifi-bootstrap.log</file> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <!-- 
       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'. 
      --> 
      <fileNamePattern>/var/log/nifi/archive/nifi-bootstrap_%d.log</fileNamePattern> 
      <!-- keep 5 log files worth of history --> 
      <maxHistory>5</maxHistory> 
     </rollingPolicy> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> 
     </encoder> 
    </appender> 

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> 
     </encoder> 
    </appender> 

     <!-- Start : Added for log for custom processor --> 
     <appender name="SQLSERVER-CDC" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>/var/log/nifi/sqlserver-cdc.log</file> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <!-- 
       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'. 
      --> 
      <fileNamePattern>/var/log/nifi/archive/sqlserver-cdc_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> 
      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> 
       <maxFileSize>25MB</maxFileSize> 
      </timeBasedFileNamingAndTriggeringPolicy> 
      <!-- keep 30 log files worth of history --> 
      <maxHistory>3</maxHistory> 
     </rollingPolicy> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> 
      <immediateFlush>true</immediateFlush> 
     </encoder> 
    </appender> 
     <!-- End : Added for log for custom processor --> 

    <!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR --> 

    <logger name="org.apache.nifi" level="INFO"/> 
    <logger name="org.apache.nifi.processors" level="WARN"/> 
    <logger name="org.apache.nifi.processors.standard.LogAttribute" level="INFO"/> 
    <logger name="org.apache.nifi.controller.repository.StandardProcessSession" level="WARN" /> 


    <logger name="org.apache.zookeeper.ClientCnxn" level="ERROR" /> 
    <logger name="org.apache.zookeeper.server.NIOServerCnxn" level="ERROR" /> 
    <logger name="org.apache.zookeeper.server.NIOServerCnxnFactory" level="ERROR" /> 
    <logger name="org.apache.zookeeper.server.quorum" level="ERROR" /> 
    <logger name="org.apache.zookeeper.ZooKeeper" level="ERROR" /> 
    <logger name="org.apache.zookeeper.server.PrepRequestProcessor" level="ERROR" /> 
    <logger name="org.apache.calcite.runtime.CalciteException" level="OFF" /> 
    <logger name="org.apache.curator.framework.recipes.leader.LeaderSelector" level="OFF" /> 
    <logger name="org.apache.curator.ConnectionState" level="OFF" /> 

    <!-- Logger for managing logging statements for nifi clusters. --> 
    <logger name="org.apache.nifi.cluster" level="INFO"/> 

    <!-- Logger for logging HTTP requests received by the web server. --> 
    <logger name="org.apache.nifi.server.JettyServer" level="INFO"/> 

    <!-- Logger for managing logging statements for jetty --> 
    <logger name="org.eclipse.jetty" level="INFO"/> 

    <!-- Suppress non-error messages due to excessive logging by class or library --> 
    <logger name="com.sun.jersey.spi.container.servlet.WebComponent" level="ERROR"/> 
    <logger name="com.sun.jersey.spi.spring" level="ERROR"/> 
    <logger name="org.springframework" level="ERROR"/> 

    <!-- Suppress non-error messages due to known warning about redundant path annotation (NIFI-574) --> 
    <logger name="com.sun.jersey.spi.inject.Errors" level="ERROR"/> 

    <!-- 
     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. 
    --> 
    <logger name="org.apache.nifi.web.security" level="INFO" additivity="false"> 
     <appender-ref ref="USER_FILE"/> 
    </logger> 
    <logger name="org.apache.nifi.web.api.config" level="INFO" additivity="false"> 
     <appender-ref ref="USER_FILE"/> 
    </logger> 
    <logger name="org.apache.nifi.authorization" level="INFO" additivity="false"> 
     <appender-ref ref="USER_FILE"/> 
    </logger> 
    <logger name="org.apache.nifi.cluster.authorization" level="INFO" additivity="false"> 
     <appender-ref ref="USER_FILE"/> 
    </logger> 
    <logger name="org.apache.nifi.web.filter.RequestLogger" level="INFO" additivity="false"> 
     <appender-ref ref="USER_FILE"/> 
    </logger> 


    <!-- 
     Logger for capturing Bootstrap logs and NiFi's standard error and standard out. 
    --> 
    <logger name="org.apache.nifi.bootstrap" level="INFO" additivity="false"> 
     <appender-ref ref="BOOTSTRAP_FILE" /> 
    </logger> 
    <logger name="org.apache.nifi.bootstrap.Command" level="INFO" additivity="false"> 
     <appender-ref ref="CONSOLE" /> 
     <appender-ref ref="BOOTSTRAP_FILE" /> 
    </logger> 

    <!-- Everything written to NiFi's Standard Out will be logged with the logger org.apache.nifi.StdOut at INFO level --> 
    <logger name="org.apache.nifi.StdOut" level="INFO" additivity="false"> 
     <appender-ref ref="BOOTSTRAP_FILE" /> 
    </logger> 

    <!-- Everything written to NiFi's Standard Error will be logged with the logger org.apache.nifi.StdErr at ERROR level --> 
    <logger name="org.apache.nifi.StdErr" level="ERROR" additivity="false"> 
     <appender-ref ref="BOOTSTRAP_FILE" /> 
    </logger> 

    <!-- Start : Added for log for custom processor --> 
    <logger name="com.datalake.processors.SQLServerCDCProcessor" level="DEBUG" > 
     <appender-ref ref="SQLSERVER-CDC"/> 
    </logger> 
    <!-- End : Added for log for custom processor --> 

    <root level="INFO"> 
     <appender-ref ref="APP_FILE"/> 
    </root> 

</configuration> 

奇妙な事実があること、カスタムプロセッサデバッグステートメントは 'nifi-app.log'と 'sqlserver-cdc.log'の両方に書き込まれますが、これらのステートメントは後者( 'sqlserver-cdc.log')にのみ書き込まれます。

私には何が欠けていますか?

答えて

2

私は問題は、com.datalake.processors.SQLServerCDCProcessorもルートロガー設定の対象であると思います。あなたはadditivity="false"を追加することによってこの問題を解決できる場合があります。

<logger name="com.datalake.processors.SQLServerCDCProcessor" level="DEBUG" additivity="false" > 
    <appender-ref ref="SQLSERVER-CDC"/> 
</logger> 

はルートロガー対加法の詳細についてはLockback exclude logger from rootを参照してください。

関連する問題