Hi, I am writing a program which is using taglib to read audio tags. When calling the taglib dll, sometimes a std::cerr message is generated. I want to catch these messages and save them in a log. I have tried
std::ofstream ostr("log.txt"); //or std::ostringstream ostr;
std::streambuf * old_buffer = std::cerr.rdbuf();

which works well for std::cerr messages made from within my program, but the std::cerr messages from the dll are not captured. Any clues?

When you run your program from the command line, redirect stderr to a file: $ myprogram 2> log.txt

The program is a GUI :-) Without a console

Open the stderr log file for writing (with CreateFile ).
Call SetStdHandle( STD_ERROR_HANDLE, log_file_handle ) ; to redirect stderr for the process to the log file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.