我正在使用以下链接中的示例。
我的代码如下。
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/from_stream.hpp>
#include <boost/log/utility/setup/settings.hpp>
#include <boost/log/utility/setup/from_settings.hpp>
#include <boost/regex.hpp>
namespace logging = boost::log;
namespace keywords = boost::log::keywords;
#define BOOST_LOG_DYN_LINK 1
int main(int, char*[])
{
//init_logging();
std::ifstream file("settings.ini");
logging::init_from_stream(file);
BOOST_LOG_TRIVIAL(trace) << "This is a trace severity message";
BOOST_LOG_TRIVIAL(debug) << "This is a debug severity message";
BOOST_LOG_TRIVIAL(info) << "This is an informational severity message";
BOOST_LOG_TRIVIAL(warning) << "This is a warning severity message";
BOOST_LOG_TRIVIAL(error) << "This is an error severity message";
BOOST_LOG_TRIVIAL(fatal) << "and this is a fatal severity message";
return 0;
}
我的 settings.ini 文件如下所示。
# Logging core settings section. May be omitted if no parameters specified within it.
[Core]
DisableLogging=false
Filter="%Severity% > 3"
# Sink settings sections
[Sinks.MySink1]
# Sink destination type
Destination=TextFile
FileName="MyApp.log"
RotationSize=1024
# Formatter string. Optional, by default only log record message text is written.
Format="<%TimeStamp%> - %Message%"
# The flag shows whether the sink should be asynchronous
Asynchronous=false
但是没有文件被创建。我究竟做错了什么?