Boost.Log问题

时间:2013-12-19 16:35:17

标签: c++ boost-log

我对Boost.Log有一些问题:这是一个片段:

#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>

int main()
{
    namespace logging = boost::log;
    namespace src = boost::log::sources;
    namespace expr = boost::log::expressions;
    namespace keywords = boost::log::keywords;
    namespace sinks = boost::log::sinks;

    logging::add_file_log (
        keywords::file_name = "sample_%N.log",
        keywords::rotation_size = 10 * 1024 * 1024,
        keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
        keywords::format = "%TimeStamp% [%Uptime%] (%LineID%) <%Severity%>: %Message%"
     );

   BOOST_LOG_TRIVIAL( trace ) << "Message";

   return 0;

}

我有以下输出:

[] () <>: Message

似乎格式不起作用......我错了什么?

1 个答案:

答案 0 :(得分:1)

虽然您的问题不完整,但我猜您错过了属性定义,即在设置日志文件后尝试添加类似内容:

logging::add_common_attributes();