If you have requirements on the time it takes to spend on your hard drive, you may need to write it yourself;
Just like the fprintf we usually use for output, for performance reasons, the functions of the runtime library are buffered (the cache is usually around 4K, but not necessarily); buffering can reduce the number of system calls; you may adjust fprintf several times , there will be one write call to actually write to the hard disk;
If you implement it yourself, for real-time considerations, directly use the system call interface write() to record logs;
If there is a buffer tolerance of 1 minute, you can use fprintf when writing logs, but call fflush() once every minute to force the logs to fall to the hard disk;
PS: If there is such a strong flash interface on log4j, you can check the information;
No, in order to improve performance, memory buffering and disk buffering technology must be used.
If you have requirements on the time it takes to spend on your hard drive, you may need to write it yourself;
Just like the fprintf we usually use for output, for performance reasons, the functions of the runtime library are buffered (the cache is usually around 4K, but not necessarily); buffering can reduce the number of system calls; you may adjust fprintf several times , there will be one write call to actually write to the hard disk;
If you implement it yourself, for real-time considerations, directly use the system call interface write() to record logs;
If there is a buffer tolerance of 1 minute, you can use fprintf when writing logs, but call fflush() once every minute to force the logs to fall to the hard disk;
PS: If there is such a strong flash interface on log4j, you can check the information;