我对配置 boost::log 有很大的问题。我需要设置最大日志文件大小。我试图这样做:
// Create a text file sink
typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_multifile_backend > file_sink;
// set log file size
boost::shared_ptr< boost::log::sinks::text_file_backend > backend =
boost::make_shared< boost::log::sinks::text_file_backend >(
boost::log::keywords::rotation_size = 1 * 1024 * 1024
);
boost::shared_ptr< file_sink > sink(new file_sink(backend));
// Set up how the file names will be generated
sink->locked_backend()->set_file_name_composer(boost::log::sinks::file::as_file_name_composer(
boost::log::expressions::stream << "logs/" << boost::log::expressions::attr< std::string >("logger_name") << ".log"));
但它甚至没有编译:/。
错误 1 错误 C2664:'boost::log::v2s_mt_nt5::sinks::text_multifile_backend::text_multifile_backend(const boost::log::v2s_mt_nt5::sinks::text_multifile_backend &)':无法从 'const boost: 转换参数 1: :shared_ptr' 到 'const boost::log::v2s_mt_nt5::sinks::text_multifile_backend &' ....................\boost_1_54_0\boost\smart_ptr\make_shared_object。第 259 节
如何配置日志文件大小?