Solved

Logging with boost to both console and file

Posted on 2014-01-20
3
1,468 Views
Last Modified: 2014-01-20
There is good example to log to either console or file. But how do you configure to log to console and file at the same time?

I am using Boost 1.55.0

Thanks
0
Comment
Question by:tommym121
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
You could add multiple sinks to the logger, e.g. like

boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend> fileSink;
boost::log::sinks::synchronous_sink< boost::log::sinks::text_ostream_backend> consoleSink;

//...

boost::log::core::get()->add_sink(fileSink);
boost::log::core::get()->add_sink(consoleSink);

Open in new window

0
 

Author Closing Comment

by:tommym121
Comment Utility
Thanks.
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
You're most welcome ;o)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now