カスタムstreambufの派生クラスを記述する必要があります。 ofstreamのrdbufと元のclog rdbufの両方にデータを吐き出しましたか?
カスタムストリームバッファの書き込みの一般的な例:次のように新しいストリームバッファを隠しておく
http://www.dreamincode.net/code/snippet2499.htm
を行うことができます。
// grab buffer for clog
std::streambuf* oldClogBuf = std::clog.rdbuf();
// create custom buffer which feeds both clog and an ofstream
CustomBuffer* customBuf = new CustomBuffer(oldClogBuf);
// stash custom buffer
std::clog.rdbuf(customBuf);
...do stuff...
// restore original clog buffer
std::clog.rdbuf(oldClogBuf);
あなたが使用して全体のことをより堅牢にすることができますバッファの切り替えを管理するRAIIのイディオム。
同じ質問を二度もしないでください。http://stackoverflow.com/questions/937805/how-to-redefine-clog-to-tee-to-original-clog-and-a-log-file – lothar