C++ Boost - 无法解析命名空间成员或容器

C++ Boost - Can't resolve namespace member or container

我正在尝试遵循 this Boost 教程,但无法弄清楚命名空间和容器无法识别的原因。我看了又看都无济于事。任何帮助将不胜感激。


代码如下:

/**
 * Boost Logger Test
 */

#include <boost/log/core/core.hpp>

namespace logging = boost::log;
namespace expr = boost::log::expressions;
namespace sinks = boost::log::sinks;

enum severity_level
{
    normal,
    notification,
    warning,
    error,
    critical
};

void init()
{
    boost::shared_ptr< logging::core > core = logging::core::get();

    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%]: %Message%"
            );

    logging::core::get()->set_filter
            (
                    logging::trivial::severity >= logging::trivial::info
            );
}

int main(int argc, char* argv[]) {
    init();
    return 0;
}

你必须

#include <boost/log/utility/setup/file.hpp>
#include <boost/log/trivial.hpp> 

并添加

namespace keywords = boost::log::keywords;