使用 log4cxx

参考地址:http://blog.19lou.com/10143734/viewspace-157322

#include "log4cxx/logger.h"
#include
"log4cxx/basicconfigurator.h"
#include
"log4cxx/helpers/exception.h"

using namespace std;
using namespace log4cxx;
using namespace log4cxx::helpers;

int main(int argc, char* argv[])
{
LoggerPtr logger(Logger::getLogger(
"MyApp"));

try
{
BasicConfigurator::configure();
LOG4CXX_INFO(logger,
"你说hello");
LOG4CXX_DEBUG(logger,
"world");
}
catch (Exception&)
{

}
return 0;
}

 

编译:g++ -g -Wall -O0 log.cpp -o log -llog4cxx 

 

你可能感兴趣的:(log)