9
如何配置boost日誌,用於旋轉和追加書寫?如何配置boost日誌,用於旋轉和追加書寫?
重啓程序後,不要清除日誌文件。
int init_log()
{
typedef sinks::synchronous_sink<sinks::text_file_backend> file_sink;
boost::shared_ptr<file_sink> sink(new file_sink (
keywords::file_name = "app.log", // only one files
// keywords::open_mode = (std::ios::out | std::ios::app), // is not append
keywords::open_mode = (std::ios::out | std::ios::app), // is not rotated
keywords::rotation_size = 10 * 1024
));
}
我不知道如何做到這一點,但log4cpp做這一切,並得到廣泛應用。 http://log4cpp.sourceforge.net/api/classlog4cpp_1_1RollingFileAppender.html –
可能的重複[Boost.Log - 如何配置文本接收器後端以追加到旋轉的文件](http://stackoverflow.com/questions/8418917/ boost-log-how-to-configure-a-text-sink-backend-append-to-rotated-files) –