Boost logo

Boost :

From: Boris (boriss_at_[hidden])
Date: 2008-08-20 13:07:35


On Wed, 20 Aug 2008 18:27:39 +0200, Andrey Semashev
<andrey.semashev_at_[hidden]> wrote:

Hi Andrey,

> [...]
>> If I
>> use boost::log::formatters::attr("TimeStamp") nothing is written to the
>> log file.
>
> That's odd. Could you send a short code sample that shows the problem?

here's the entire program:

----------
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/logging_core.hpp>
#include <boost/log/utility/init/to_file.hpp>
#include <boost/log/utility/init/common_attributes.hpp>
#include <boost/log/formatters/format.hpp>
#include <boost/log/formatters/attr.hpp>
#include <boost/log/formatters/message.hpp>
#include <boost/shared_ptr.hpp>

boost::log::sources::severity_logger logger;

int main()
{
boost::log::add_common_attributes();

boost::shared_ptr<boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend>>
sink = boost::log::init_log_to_file("test.txt");

sink->locked_backend()->set_formatter(boost::log::formatters::format("[%1%]
%2%") %
boost::log::formatters::attr("TimeStamp") %
boost::log::formatters::message());

sink->locked_backend()->auto_flush(true);

BOOST_LOG(logger) << "message";
}
----------

If I build it with VC++ 9.0 SP1 the file test.txt contains afterwards:

[] message

Only if I use boost::log::formatters::date_time("TimeStamp") the timestamp
is written.

Boris

> [...]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk