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

时间:2015-04-07 21:28:38

标签: c++ boost

我试图关注this Boost教程,无法弄清楚为什么命名空间和容器无法识别。我看起来并且看起来无济于事。任何帮助将不胜感激。

enter image description here


以下是代码:

/**
 * 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;
}

1 个答案:

答案 0 :(得分:3)

你必须

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

并添加

namespace keywords = boost::log::keywords;
相关问题