Open tversic opened 11 months ago
For one, I just noticed that immediateFlush
isn't even used in RollingFileAppender
despite being an option. Let's see what else is broken because of this >_>
Hi,@jvz
RandomAccessFile
FileChannel channel = randomAccessFile.getChannel();
randomAccessFile.write();
channel.force(true);
Use the force method,the file be updated in real time. But affects performance. Log4j2,not use the force method. Rewrite RollingRandomAccessFileManager and RandomAccessFileManager flush method. Add the code above. Or add the above code when rolling over the file.
@tcmot,
Thanks for the suggestion. Your solution will cause two system calls (a write
and an fsync/fdatasync
on Linux) to be issued for each log event. I would rather use:
StandardOpenOption#DSYNC/SYNC
option to Files#newOutputStream
,rwd/rws
mode for RandomAccessFile
.These have the advantage to delegate the syncing part to the OS, which can do it much more efficiently.
Of course such a behavior should be optional, since most users don't care when the OS synchronizes its I/O buffers with the disk storage.
Issue #2117 is related to this.
Hey guys, I have already asked this question on the discussion page and it seems like that post isnt getting any reach so I am writing this issue here again, I hope that is not problem and that someone will be able to clear things out a little for me.
Since writing same thing twice doesnt make much sense I will be linking discussion below, so someone can take a look and comment if there is any idea on the problem.
issue: https://github.com/apache/logging-log4j2/discussions/2004
Thank you!