I try to log with Boost library 1.61, rotating file once size exceeded 5Ko. But, every time program runs, it begins from the first log file, exceeding max size !
That is, it appends text to flog000.txt, then to flog001.txt.
But the desired behaviour was: append to the last file (flog002.txt) then continue with flog003.txt...
Here is my code:
#include <boost/log/common.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/core.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
void init()
{
boost::log::add_file_log
(
boost::log::keywords::file_name = "flog%3N.txt",
boost::log::keywords::open_mode = std::ios_base::app,
boost::log::keywords::rotation_size = 5 * 1024,
boost::log::keywords::auto_flush = true
);
}
int main()
{
init();
boost::log::sources::logger lg;
boost::log::add_common_attributes();
for (int i(0); i < 1000; ++i)
{
BOOST_LOG(lg) << "Hello : " << i << std::endl;
}
return 0;
}