-
Notifications
You must be signed in to change notification settings - Fork 478
Open
Description
Regarding the rotation of q2 logs, I have configured the following content in the 00_logger.xml file to test the rotation and deletion of q2 logs, but the functionality to delete expired files is not working.
<log-listener class="org.jpos.util.DailyLogListener">
<property name="window" value="86400" />
<property name="prefix" value="logs/q2/" />
<property name="suffix" value="q2.log"/>
<property name="date-format" value="yyyy-MM-dd-HH"/>
<property name="compression-format" value="gzip"/>
<property name="maxsize" value="10000000"/>
<property name="maxage" value="86400"/>
</log-listener>
I have checked and debugged the source code and found that the issue lies in the DEF_MAXDEPTH parameter. The parameter determines the depth of file queries and has a default value of 1. As a result, it cannot find expired files under the "logs/q2" directory. I suggest making this parameter configurable in the 00_logger.xml file.
try {
Files.find(logBasePath, DEF_MAXDEPTH,
(path, attributes) ->
path.getFileName().toString().matches(deleteRegex)
&& attributes.isRegularFile()
&& currentSystemTime - attributes.lastModifiedTime().toMillis() >= maxAge)
.forEach(path -> {
try {
Files.delete(path);
} catch (IOException e) {
e.printStackTrace(System.err);
}
});
} catch (IOException e) {
e.printStackTrace(System.err);
}
ar
Metadata
Metadata
Assignees
Labels
No labels