1: #include <iostream>
2: #include <fstream>
3: using namespace std;
4:
5: int main(){
6: ofstream out;
7: out.open("i://t.txt",ios::app);
8: streambuf *backup = clog.rdbuf();
9: clog.rdbuf(out.rdbuf());
10: clog<<"my log..."<<endl;
11: out.close();
12: clog.rdbuf(backup);//必须重定向回来
13:
14: }