Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding possibility for force flushing current file buffer #233

Open
AJIOB opened this issue Nov 30, 2022 · 4 comments
Open

Adding possibility for force flushing current file buffer #233

AJIOB opened this issue Nov 30, 2022 · 4 comments

Comments

@AJIOB
Copy link

AJIOB commented Nov 30, 2022

Sometimes will be interested in force flushing RollingFileAppender data for next backuping them into different storages.

I usually have only one file for logging (without any backup). That is why it is not possible for using rollLogFiles() call.

If user wants to force use flush, it will be also good for providing all collected logs without removing any part of collected logs. Force rolling removes last of them - and that is not looks like a good choice for that case.

@SergiusTheBest
Copy link
Owner

Log data is written directly to a file without any intermediate buffering in the app. So I'm not sure what flushing do you need. Could you provide more details?

@AJIOB
Copy link
Author

AJIOB commented Dec 6, 2022

@SergiusTheBest
As you know, any OS and libc have possibility for using file buffering internally for optimization purposes (block writing and so on).

And a programmer can force write that buffers to HDD/SSD/... by special API call.

C/C++ has few standardized API for flushing data:

If you need to use raw OS calls, you can use sync() Linux call for that purposes:

I think that Windows provides the similar API for that operation too.

With regards,
Alex

@SergiusTheBest
Copy link
Owner

Oh, I think I see your problem. Your backup system works on the block level so you want the log data to be written on the disk. Is that correct?

@AJIOB
Copy link
Author

AJIOB commented Dec 6, 2022

Yes, you are right.

Also, glibc uses internal RAM buffers too, as I know, and another process sometimes have no possibility for accessing the latest file changes on HDD/SSD...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants