为什么我的 nifi 不能将日志分成小部分?

问题描述

关于 nifi 1.6 的问题。

我尝试使用 logback 将日志分成小部分,但 logback 配置似乎不起作用。

这是我的配置。

    <appender name="APP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${org.apache.nifi.bootstrap.config.log.dir}/nifi-app.log</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

            <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/daily/app_%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <maxFileSize>1MB</maxFileSize>
            <maxHistory>15</maxHistory>
        </rollingPolicy>
        <!--<immediateFlush>true</immediateFlush> -->
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>

这里是 cmd 中的标准输出

12:43:19,838 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/nifi-1.6.0-bin/nifi-1.6.0/conf/logback.xml]
12:43:19,893 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:43:19,899 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:/D:/nifi-1.6.0-bin/nifi-1.6.0/conf/logback.xml]
12:43:19,899 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 30 seconds
12:43:19,901 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Adding LoggerContextListener of type [ch.qos.logback.classic.jul.LevelChangePropagator] to the object stack
12:43:19,909 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@34ce8af7 - Propagating DEBUG level on Logger[ROOT] onto the JUL framework
12:43:19,909 |-INFO in ch.qos.logback.classic.joran.action.LoggerContextListenerAction - Starting LoggerContextListener
12:43:19,909 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:43:19,912 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [APP_FILE]
12:43:19,953 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@191382150 - No compression will be used
12:43:19,954 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@191382150 - Will use the pattern D:/nifi-1.6.0-bin/nifi-1.6.0/bin/..//logs/daily/app_%d{yyyy-MM-dd}.%i.log for the active file
12:43:19,956 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@880ec60 - The date pattern is 'yyyy-MM-dd' from file name pattern 'D:/nifi-1.6.0-bin/nifi-1.6.0/bin/..//logs/daily/app_%d{yyyy-MM-dd}.%i.log'.
12:43:19,956 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@880ec60 - Roll-over at midnight.
12:43:19,958 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@880ec60 - Setting initial period to Thu Jan 07 12:42:43 CST 2021
12:43:19,959 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@880ec60 - SizeAndTimeBasedFNATP is deprecated. Use SizeAndTimeBasedRollingPolicy instead
12:43:19,959 |-WARN in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@880ec60 - For more information see http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy
12:43:19,978 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[APP_FILE] - Active log file name: D:\nifi-1.6.0-bin\nifi-1.6.0\bin\..\\logs/nifi-app.log
12:43:19,978 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[APP_FILE] - File property is set to [D:\nifi-1.6.0-bin\nifi-1.6.0\bin\..\\logs/nifi-app.log]

在log目录下,当app.log大于1MB时, daily 目录已创建,但 daily 中没有日志文件

我想知道nifi中的logback(或不用于spring)是否只能按时间拆分日志?

spring boot 2.x 中的相同配置正在工作,换句话说,日志可以按大小拆分。

logback 版本是 1.2.3。我尝试使用 SizeAndTimeBasedRollingPolicy 更新 logback 配置,我得到了相同的结果。

):

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)