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.

35 lines
957 B

  1. #include <log4cplus/logger.h>
  2. #include <log4cplus/fileappender.h>
  3. #include <log4cplus/layout.h>
  4. #include <log4cplus/ndc.h>
  5. #include <log4cplus/helpers/loglog.h>
  6. #include <log4cplus/loggingmacros.h>
  7. using namespace log4cplus;
  8. const int LOOP_COUNT = 20000;
  9. int
  10. main()
  11. {
  12. helpers::LogLog::getLogLog()->setInternalDebugging(true);
  13. SharedAppenderPtr append_1(
  14. new RollingFileAppender(LOG4CPLUS_TEXT("Test.log"), 5*1024, 5));
  15. append_1->setName(LOG4CPLUS_TEXT("First"));
  16. append_1->setLayout( std::auto_ptr<Layout>(new TTCCLayout()) );
  17. Logger::getRoot().addAppender(append_1);
  18. Logger root = Logger::getRoot();
  19. Logger test = Logger::getInstance(LOG4CPLUS_TEXT("test"));
  20. Logger subTest = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest"));
  21. for(int i=0; i<LOOP_COUNT; ++i) {
  22. NDCContextCreator _context(LOG4CPLUS_TEXT("loop"));
  23. LOG4CPLUS_DEBUG(subTest, "Entering loop #" << i);
  24. }
  25. return 0;
  26. }