title: Redirect C++ std::clog to syslog on Unix
body: <p>I work on Unix on a C++ program that send messages to syslog.</p>
  
  <p>The current code uses the <strong>syslog</strong> system call that works like printf.</p>
  
  <p>Now I would prefer to use a stream for that purpose instead, typically the built-in <strong>std::clog</strong>. But clog merely redirect output to stderr, not to syslog and that is useless for me as I also use stderr and stdout for other purposes.</p>
  
  <p>I've seen in <a href="https://stackoverflow.com/questions/665509/redirecting-standard-output-to-syslog">another answer</a>  that it's quite easy to redirect it to a file using rdbuf() but I see no way to apply that method to call syslog as openlog does not return a file handler I could use to tie a stream on it.</p>
  
  <p>Is there another method to do that ? (looks pretty basic for unix programming) ? </p>
  
  <p><strong>Edit:</strong> I'm looking for a solution that does not use external library. What @Chris is proposing could be a good start but is still a bit vague to become the accepted answer.</p>
  
  <p><strong>Edit</strong>: using Boost.IOStreams is OK as my project already use Boost anyway.</p>
  
  <p>Linking with external library is possible but is also a concern as it's GPL code. Dependencies are also a burden as they may conflict with other components, not be available on my Linux distribution, introduce third-party bugs, etc. If this is the only solution I may consider completely avoiding streams... (a pity).</p>