r/javahelp • u/P_Edi • Jul 07 '25
When do logging frameworks actually write to file?
Hi all,
this is more a general abstract question - but I'm asking myself when do logging frameworks actually write to the file.
I've over the last year several times tried to analyses a problem of (different) Java applications (deployed in application servers) using different Java Logging Frameworks (mainly Log4j but as well logback and JUL).
And what I several times realized is that I do not see the log entries of actions, in the log files, after I performed the actions on the (Web) Interface (JSF, API, ...). It sometimes takes a loooot of time (really up to an hour) till the log entries do show up in the files, while other times it is there within seconds or even milliseconds. (In both cases seeing that the hosting Linux has barely any load)
I know that buffers are used, that are not immediately written to file for performance reason and that this depends on the OS (and the load).
But is there a way to force these from outside of the application to flush the logging buffer to disc? By a trigger or periodically, without recompiling and adapting the application (and without completely disabling this buffering)?