1 // testNTEventLog.cpp : Derived from testPattern.cpp. 2 // 3 4 #include "log4cpp/Portability.hh" 5 6 #ifdef WIN32 7 #include <windows.h> 8 #endif 9 #ifdef LOG4CPP_HAVE_UNISTD_H 10 #include <unistd.h> 11 #endif 12 13 #include <stdlib.h> 14 15 #include "log4cpp/Category.hh" 16 #include "log4cpp/Appender.hh" 17 #include "log4cpp/NTEventLogAppender.hh" 18 #include "log4cpp/Priority.hh" 19 main(int argc,char * argv[])20int main(int argc, char* argv[]) 21 { 22 log4cpp::Appender* appender = 23 new log4cpp::NTEventLogAppender("default", "testNTEventLog"); 24 25 log4cpp::Category& sub1 = 26 log4cpp::Category::getInstance(std::string("sub1")); 27 sub1.addAppender(appender); 28 sub1.setPriority(log4cpp::Priority::DEBUG); 29 30 sub1.emerg("sub1 emerg"); 31 sub1.fatal("sub1 fatal"); 32 sub1.alert("sub1 alert"); 33 sub1.crit("sub1 crit"); 34 sub1.error("sub1 error"); 35 sub1.warn("sub1 warn"); 36 sub1.notice("sub1 notice"); 37 sub1.info("sub1 info"); 38 sub1.debug("sub1 debug"); 39 sub1.log(log4cpp::Priority::NOTSET, "sub1 notset"); 40 sub1.log(log4cpp::Priority::ERROR, "sub1 error"); 41 42 log4cpp::Category::shutdown(); 43 44 return 0; 45 } 46 47