Wildfly, how to force programmatically the flush of server log file when autoflush = false

153 Views Asked by At

for performance reason I have set the property autofush=false in the subsystem urn:jboss:domain:logging:

<periodic-size-rotating-file-handler name="FILE" autoflush="false">

WildFly does not immediately flush the server.log file but does so according to some policy of its own.

In some scenarios, however, it is necessary to have the latest information available in the server.log without wait that WildFly decides to flush

I have seen that it is possible to change the autoflush flag setting 'on the fly' using wildfly's management console: this causes an immediate flush of the latest information in the server.log but also changes the configuration of xml file of the application.

The best option would be to be able to force the flush on demand without the need to change the application configuration file, but after several searches I have not found any way to do this.

I only found a less-than-elegant way: run a bunch of useless System.out in order to force JBoss to flush

I also tried putting in an application:

System.out.flush();

But no flush is executed.

I have tried using WildFly 26

0

There are 0 best solutions below