For wildfly (on linux) I need following logging scenario: daily rotation of server.log
and removing old log files which are older than 90 days. I don't see a way to configure this in wildfly/log4j (the problem is here to remove old log files, but I will be happy for tips to do this directly with wildfly configuration). So I have to use linux logrotate for this. I have following logrotate configuration file:
/var/log/wildfly/capp/*.log {
missingok
daily
notifempty
rotate 90
maxage 90
dateext
dateformat -%Y%m%d
}
The server.log
will be rotated successfully in the early morning. But: wildfly is still writing the log messages into the already logrotated file (see at the timestamps of the last write access):
#> ls -la
-rw-r--r-- 1 wildfly-capp wildfly-capp 0 4. Apr 03:40 server.log
-rw-r--r-- 1 wildfly-capp wildfly-capp 368909 4. Apr 07:00 server.log-20190404
Is there a way to force wildfly to use the server.log
file instead the already rotated file (without restarting wildfly)? Or is it possible to change the wildfly logging configuration to remove logging files which are older than x
days?
The wildfly logging configuration is:
<subsystem xmlns="urn:jboss:domain:logging:5.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<append value="true"/>
</file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>