You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

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