1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/helpers/stringhelper.h>
using namespace std;
using namespace log4cplus;
using namespace log4cplus::helpers;
int
main()
{
cout << "Entering main()..." << endl;
LogLog::getLogLog()->setInternalDebugging(true);
Logger root = Logger::getRoot();
try {
PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
Logger fileCat = Logger::getInstance(LOG4CPLUS_TEXT("filelogger"));
LOG4CPLUS_WARN(root, "Testing....");
LOG4CPLUS_WARN(root, "Writing messages to log....");
for(int i=0; i<10000; ++i) {
LOG4CPLUS_WARN(fileCat, "This is a WARNING..." << i);
}
}
catch(...) {
cout << "Exception..." << endl;
LOG4CPLUS_FATAL(root, "Exception occured...");
}
cout << "Exiting main()..." << endl;
return 0;
}
|