这是我的代码:
#include <boost/log/trivial.hpp>
#include <boost/move/utility.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/sources/global_logger_storage.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace keywords = boost::log::keywords;
BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(my_logger, src::logger_mt)
void Foo::Some()
{
std::cout << "TEST";
src::logger_mt& lg = my_logger::get();
logging::add_file_log("F:\\sample.log");
//logging::core::get()->set_filter
// (
// logging::trivial::severity >= logging::trivial::info
// );
logging::add_common_attributes();
BOOST_LOG(lg) << "Greetings from the global logger!";
它取自 boost 教程,但它不会写入文件,也不会显示任何错误消息
教程在这里: http: //www.boost.org/doc/libs/master/libs/log/example/doc/tutorial_file.cpp
我究竟做错了什么?
它没有线工作:logging::add_file_log("F:\\sample.log");
但我尝试了不同的文件位置,它没有写任何地方