Rob*_*edy 14
该功能内置于文本接收器,文档中包含一个示例,用于设置文件名模式以及以特定大小和时间旋转的规则:
// The function registers file sink in the logging library
void init_logging()
{
boost::shared_ptr< logging::core > core = logging::core::get();
boost::shared_ptr< sinks::text_file_backend > backend =
boost::make_shared< sinks::text_file_backend >(
// file name pattern
keywords::file_name = "file_%5N.log",
// rotate the file upon reaching 5 MiB size...
keywords::rotation_size = 5 * 1024 * 1024,
// ...or at noon, whichever comes first
keywords::time_based_rotation = sinks::file::rotation_at_time_point(12, 0, 0)
);
// Wrap it into the frontend and register in the core.
// The backend requires synchronization in the frontend.
typedef sinks::synchronous_sink< sinks::text_file_backend > sink_t;
boost::shared_ptr< sink_t > sink(new sink_t(backend));
core->add_sink(sink);
}
Run Code Online (Sandbox Code Playgroud)
显然没有办法使用此设置使库附加到现有文件.您应该backend->scan_for_files();在构建之前调用sink,如文档中的"管理旋转文件"标题所示,但这只会阻止库在它们到期之前覆盖以进行清理.
当该主题在2013年2月的开发邮件列表中出现时,该库的作者解释说,添加对附加的支持将是一个无法在当前设计下进行的重大更改.
| 归档时间: |
|
| 查看次数: |
9486 次 |
| 最近记录: |