簡體   English   中英

Boost.Log問題

[英]Boost.Log Issue

我在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

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

盡管您的問題不完整,但我的猜測是您缺少屬性定義,即在設置日志文件后嘗試添加如下內容:

logging::add_common_attributes();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM