I tried to do this to redirect the clog output to a file:
ofstream ofs("file.log");
clog.rdbuf(ofs.rdbuf());
clog << "Logged." << endl;
ofs.close();
It worked (the file contains the text), but the program segfaults. I read that you have to "restore" the original buffer, so I tried this
ofstream ofs("file.log");
clog.rdbuf(ofs.rdbuf());
clog << "Logged." << endl;
ofs.close();
clog.rdbuf(clog.rdbuf());
But no change. Anyone know how to do this?
Thanks,
Dave