Solved

Logging with boost to both console and file

Posted on 2014-01-20
3
1,523 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
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What does std::atomic give me? 7 125
c++ syntax question 9 49
Path to  STL Map header file 1 58
Error creating a new C++ project in ,net 20 36
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

831 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