Created 06-23-2017 12:48 AM
I have NiFi 1.2.0 installed on the Windows 2012 R2 server, it creates the standard logs files as under:
Issue is that these files are not rolling over daily or based on size. Can someone help? I have attached the logback.xml file.
Also, are the changes to this logback.xml dynamically implemented, or it requires NiFi to get into effect?
Created 06-23-2017 01:51 PM
I suspect that Windows locking mechanism restricts the original file to be renamed(Check http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03222.html for details).
You can omit the file property in logback.xml, and then the active log file will be computed a new for each period based on the value of fileNamePattern. A working rollingpolicy for a NiFi node on Windows is as follows:
<appender name="APP_FILE"> <!-- <file>${org.apache.nifi.bootstrap.config.log.dir}/nifi-app.log</file> --> <rollingPolicy> <!-- 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>${org.apache.nifi.bootstrap.config.log.dir}/nifi-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy> <maxFileSize>100MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- keep 30 log files worth of history --> <maxHistory>30</maxHistory> </rollingPolicy>
Created 06-23-2017 07:04 AM
Hi Avi,
Please updated the logback.xml with below correction and restart nifi to reflect the changes.
your logback.xml
<fileNamePattern> C:\NiFi\nifi-1.2.0\logs\nifi-app_%d{yyyy-MM-dd_HH}.%i.zip </fileNamePattern>
But it should be:
<fileNamePattern> C:\NiFi\nifi-1.2.0\logs\nifi-app_%d{yyyy-MM-dd_HH}.%i.log.zip </fileNamePattern>
Created 06-23-2017 01:51 PM
I suspect that Windows locking mechanism restricts the original file to be renamed(Check http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03222.html for details).
You can omit the file property in logback.xml, and then the active log file will be computed a new for each period based on the value of fileNamePattern. A working rollingpolicy for a NiFi node on Windows is as follows:
<appender name="APP_FILE"> <!-- <file>${org.apache.nifi.bootstrap.config.log.dir}/nifi-app.log</file> --> <rollingPolicy> <!-- 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>${org.apache.nifi.bootstrap.config.log.dir}/nifi-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy> <maxFileSize>100MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- keep 30 log files worth of history --> <maxHistory>30</maxHistory> </rollingPolicy>
Created 06-23-2017 07:14 PM
Thanks Shashank, logs are now rolling over on both time and size triggers. Awesome!