Search code examples
loggingqt5disable

How to disable all log of third party libraries in my Qt5 app?


I can disable all log from my app in release mode by set up qInstallMessageHandler. But there are still some log from third party libraries that I used. Is there any way to disable all log to console without modify other libraries? Thanks


Solution

  • Just an idea, but you could stream to a file the cout and cerr streams.

    #include <fstream>
    #include <iostream>
    
    int main(int argc, char *argv[]) {
      std::ofstream file;
      file.open("output.txt");
      std::streambuf *std_buffer = std::cout.rdbuf();
      std::cout.rdbuf(file.rdbuf());
    
      std::cout << "this is a log" << std::endl;
    
      return 0;
    }