应用boost.log,发现当重新启动程序时log文件被清空,求解决

使用boost.log,发现当重新启动程序时log文件被清空,求解决。
本帖最后由 ironskinspirit 于 2011-11-23 16:36:02 编辑
最近在学习boost.log,windows平台,log文件test.log和test1.log都能自动生成,但发现一个奇怪的问题,就是当重新启动程序时原有的log总被清掉,然后写入新的log。
求高人指点,程序很简单,如下:

#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/filters.hpp>
#include <boost/log/sinks.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/common.hpp>
#include <boost/log/formatters.hpp>
#include <boost/log/utility/init/to_file.hpp>
#include <boost/log/utility/init/from_stream.hpp>

namespace logging = boost::log;
namespace fmt = boost::log::formatters;
namespace flt = boost::log::filters; 
namespace attrs = boost::log::attributes;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks; 
using boost::shared_ptr;
using namespace std;

enum severity_level
{
    debug,
    info,
    warn,
    error
};

BOOST_LOG_DECLARE_GLOBAL_LOGGER(logger, src::severity_logger_mt<>)

void try_logging( std::string c )
{
    BOOST_LOG_SCOPED_THREAD_TAG("Tag", string, c.c_str());

    src::severity_logger_mt<>& lg = get_logger();

    BOOST_LOG_SEV(lg, debug) << "This is a debug severity record";
    BOOST_LOG_SEV(lg, info) << "This is a info severity record";
    BOOST_LOG_SEV(lg, warn) << "This is a warn severity record";
    BOOST_LOG_SEV(lg, error) << "This is a error severity record";
}

int _tmain(int argc, _TCHAR* argv[])
{
        ifstream settings("F:\\work\\mshtml\\logtest\\log.setting");
        if (!settings.is_open())
        {
            cout << "Could not open settings.txt file" << std::endl;
            return 1;
        }

cout << "init_from_stream" << endl;
        // Read the settings and initialize logging library
        logging::init_from_stream(settings);
cout << "end init_from_stream" << endl;
        shared_ptr< logging::attribute > attr(new attrs::local_clock);
        logging::core::get()->add_global_attribute("TimeStamp", attr);
boost::thread_group g; 
for (char i = 'a'; i < 'd'; i++){
           g.create_thread(boost::bind(&try_logging, std::string("aaa") + i));