[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Logging with boost to both console and file

Posted on 2014-01-20
3
Medium Priority
?
1,677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 39795705
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
ID: 39795912
Thanks.
0
 
LVL 86

Expert Comment

by:jkr
ID: 39795917
You're most welcome ;o)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

650 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