F
farhadtarapore
I have a very large C++ application that has been converted into a
windows service. This application writes a lot of statements to the
console i.e. cout and cerr.
I have used
std:
fstream out(coutFilePath.c_str (), ofstream:
ut |
ofstream::app);
if(!out.is_open())
throw std::runtime_error("Failed to open cout file");
//Save the previous target before we redirect
std::streambuf* orig_cout = std::cout.rdbuf( out.rdbuf());
.....
.... code that uses cout, calls lots of libraries, functions, etc...
.....
.....
//Restore the cout to previous target
std::cout.flush();
std::cout.rdbuf(orig_cout);
out.close();
//////////////////////////
My problem is this: The application cout file fills up very quickly. I
need some mechanism like a rolling file appender of Log4Cpp. How can I
implement a rolling file log in C++?
Thanks in advance.
windows service. This application writes a lot of statements to the
console i.e. cout and cerr.
I have used
std:
ofstream::app);
if(!out.is_open())
throw std::runtime_error("Failed to open cout file");
//Save the previous target before we redirect
std::streambuf* orig_cout = std::cout.rdbuf( out.rdbuf());
.....
.... code that uses cout, calls lots of libraries, functions, etc...
.....
.....
//Restore the cout to previous target
std::cout.flush();
std::cout.rdbuf(orig_cout);
out.close();
//////////////////////////
My problem is this: The application cout file fills up very quickly. I
need some mechanism like a rolling file appender of Log4Cpp. How can I
implement a rolling file log in C++?
Thanks in advance.