Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're in a posix shell environment (I'm really thinking of bash), you can redirect any file descriptor to any other file descriptor, so to redirect, you can just:</p> <pre><code>$ myprogram 2&gt;&amp;5 </code></pre> <p>to redirect stderr to the file represented by fd=5.</p> <p>Edit: on second thought, I like @Konrad Rudolph's answer about redirection better. rdbuf() is a more coherent and portable way to do it.</p> <p>As for logging, well...I start with the Boost library for all things C++ that isn't in the std library. Behold: <a href="http://www.torjo.com/log2/index.html" rel="nofollow noreferrer">Boost Logging v2</a></p> <p><strong>Edit</strong>: Boost Logging is <em>not</em> part of the Boost Libraries; it has been reviewed, but not accepted.</p> <p><strong>Edit</strong>: 2 years later, back in May 2010, Boost did accept a logging library, now called <a href="http://boost-log.sourceforge.net/libs/log/doc/html/index.html" rel="nofollow noreferrer">Boost.Log</a>.</p> <p>Of course, there are alternatives:</p> <ul> <li><a href="http://log4cpp.sourceforge.net/" rel="nofollow noreferrer">Log4Cpp</a> (a log4j-style API for C++)</li> <li><a href="http://logging.apache.org/log4cxx/index.html" rel="nofollow noreferrer">Log4Cxx</a> (Apache-sponsored log4j-style API)</li> <li><a href="http://pantheios.sourceforge.net/" rel="nofollow noreferrer">Pantheios</a> (defunct? last time I tried I couldn't get it to build on a recent compiler)</li> <li><a href="https://github.com/google/glog" rel="nofollow noreferrer">Google's GLog</a> (hat-tip @SuperElectric)</li> </ul> <p>There's also the Windows Event logger.</p> <p>And a couple of articles that may be of use:</p> <ul> <li><a href="http://www.ddj.com/cpp/201804215" rel="nofollow noreferrer">Logging in C++ (Dr. Dobbs)</a></li> <li><a href="http://developers.sun.com/solaris/articles/logging.html" rel="nofollow noreferrer">Logging and Tracing Simplified (Sun)</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload