#include #include #include #include #include #include #include using namespace std; using namespace log4cplus; using namespace log4cplus::helpers; int main() { cout << "Entering main()..." << endl; LogLog::getLogLog()->setInternalDebugging(true); try { SharedObjectPtr append_1(new ConsoleAppender()); append_1->setName(LOG4CPLUS_TEXT("First")); append_1->setLayout( std::auto_ptr(new log4cplus::TTCCLayout()) ); Logger::getRoot().addAppender(append_1); Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test")); log4cplus::tcout << "Logger: " << logger.getName() << endl; getNDC().push(LOG4CPLUS_TEXT("tsmith")); LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("This is a short test...")); getNDC().push(LOG4CPLUS_TEXT("password")); LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("This should have my password now")); getNDC().pop(); LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("This should NOT have my password now")); getNDC().pop_void (); cout << "Just returned from pop..." << endl; LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("There should be no NDC...")); getNDC().push(LOG4CPLUS_TEXT("tsmith")); getNDC().push(LOG4CPLUS_TEXT("password")); LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("This should have my password now")); getNDC().remove(); LOG4CPLUS_DEBUG(logger, LOG4CPLUS_TEXT("There should be no NDC...")); } catch(...) { cout << "Exception..." << endl; Logger::getRoot().log(FATAL_LOG_LEVEL, LOG4CPLUS_TEXT("Exception occured...")); } cout << "Exiting main()..." << endl; return 0; }