Solved

Logging with boost to both console and file

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to convert c++ code to Android App 3 132
Unresolved External Symbols 3 130
Which Linux flavors will this run on? 6 102
show out valin of json for debugging in visaul c++ 1 47
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

749 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