Boost logo

Boost :

Subject: Re: [boost] Is disabling boost log auto flush the only way to control the log flush? Or can you change log auto flush rate?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-12-13 10:00:16

On 12/13/18 6:55 AM, hh h via Boost wrote:
> Hi,
> I use boost log in an embedded system where flushing log message to
> flash storage need be controlled. I could not find how to change log
> auto flush rate, is it the only way to disable auto flush
> boost::log::keywords::auto_flush = false? I think there must be a way
> to change a desired log flush rate value without disabling auto flush,
> appreciate any tips.

Auto flush is disabled by default, you don't need to disable it explicitly.

When not enabled, the rate of flushing is system dependent - basically,
it happens when C/C++ runtime library detects its internal buffer
overflow when Boost.Log tries to write a new record to the file stream.
I'm not aware of any ways to influence that, so the flush will happen at
least that often. Additionally, you can flush the stream buffer manually
by calling flush() on the logging core or the sink at the points you
feel appropriate.

However, I should note that flushing the buffer from Boost.Log side does
not necessarily mean writing the data to the flash media. Normally, the
flush operation simply invokes the OS write operation, which places the
data in the filesystem cache to write it later. The OS may combine
multiple such write operations in the cache before the data is actually
written to the media. If it is the flash media health that concerns you,
you should research how you can tune filesystem cache in your OS first,
before tampering with your application, as this will give the most
tangible benefit, even beyond writing logs.

Boost list run by bdawes at, gregod at, cpdaniel at, john at