我对 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
似乎格式不起作用......我错了吗?