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.

66 lines
2.7 KiB

  1. #include <iostream>
  2. #include <string>
  3. #include "log4cplus/hierarchy.h"
  4. #include "log4cplus/helpers/loglog.h"
  5. using namespace std;
  6. using namespace log4cplus;
  7. using namespace log4cplus::helpers;
  8. int
  9. main()
  10. {
  11. log4cplus::initialize ();
  12. {
  13. Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test"));
  14. log4cplus::tcout << "Logger name: " << logger.getName()
  15. << " Parent = " << logger.getParent().getName() << endl;
  16. logger = Logger::getInstance(LOG4CPLUS_TEXT("test2"));
  17. log4cplus::tcout << "Logger name: " << logger.getName()
  18. << " Parent = " << logger.getParent().getName() << endl;
  19. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a.b.c"));
  20. log4cplus::tcout << "Logger name: " << logger.getName()
  21. << " Parent = " << logger.getParent().getName() << endl;
  22. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a"));
  23. log4cplus::tcout << "Logger name: " << logger.getName()
  24. << " Parent = " << logger.getParent().getName() << endl;
  25. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest"));
  26. log4cplus::tcout << "Logger name: " << logger.getName()
  27. << " Parent = " << logger.getParent().getName() << endl;
  28. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a"));
  29. log4cplus::tcout << "Logger name: " << logger.getName()
  30. << " Parent = " << logger.getParent().getName() << endl;
  31. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a.b.c"));
  32. log4cplus::tcout << "Logger name: " << logger.getName()
  33. << " Parent = " << logger.getParent().getName() << endl;
  34. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a.b.c.d"));
  35. log4cplus::tcout << "Logger name: " << logger.getName()
  36. << " Parent = " << logger.getParent().getName() << endl;
  37. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a.b.c"));
  38. log4cplus::tcout << "Logger name: " << logger.getName()
  39. << " Parent = " << logger.getParent().getName() << endl;
  40. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest.a"));
  41. log4cplus::tcout << "Logger name: " << logger.getName()
  42. << " Parent = " << logger.getParent().getName() << endl;
  43. logger = Logger::getInstance(LOG4CPLUS_TEXT("test.subtest"));
  44. log4cplus::tcout << "Logger name: " << logger.getName()
  45. << " Parent = " << logger.getParent().getName() << endl;
  46. Logger::shutdown();
  47. }
  48. log4cplus::tcout << "Exiting main()..." << endl;
  49. return 0;
  50. }