|
Boost Users : |
Subject: [Boost-users] Boost Logging File Rotation
From: Bryan Pham (bryan_at_[hidden])
Date: 2013-08-24 00:22:52
Hi I'm trying to use boost logging rotation and I'm not seeing any output
nor file is being written. The old method of using boost trivial seems to
output to stdout just fine.
My setup:
void boost_log_setup(int level)
{
//boost::log::core::get()->set_filter(boost::log::trivial::severity >=
level);
boost::shared_ptr< boost::log::core > core = boost::log::core::get();
boost::shared_ptr< boost::log::sinks::text_file_backend > backend =
boost::make_shared< boost::log::sinks::text_file_backend >(
boost::log::keywords::file_name = "cloutenna_%5N.log",
boost::log::keywords::rotation_size = 5 * 1024 * 1024,
boost::log::keywords::time_based_rotation =
boost::log::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 boost::log::sinks::synchronous_sink<
boost::log::sinks::text_file_backend > sink_t;
boost::shared_ptr< sink_t > sink(new sink_t(backend));
core->set_filter(severity >= level);
core->add_sink(sink);
}
enum severity_level
{
trace,
debug,
notification,
warning,
error,
fatal
};
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", severity_level)
BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(logger,
boost::log::sources::severity_logger_mt<>)
//Common loggin define
#define CM_TRACE BOOST_LOG_SEV(logger::get(), trace)
#define CM_DEBUG BOOST_LOG_SEV(logger::get(), debug)
#define CM_INFO BOOST_LOG_SEV(logger::get(), notification)
#define CM_WARN BOOST_LOG_SEV(logger::get(), warning)
#define CM_ERROR BOOST_LOG_SEV(logger::get(), error)
#define CM_FAIL BOOST_LOG_SEV(logger::get(), fatal)
int main(int argc, char* argv[])
{
boost_log_setup(severity_level::debug);
CM_INFO << "starting ... "
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net