使用 log4cxx 时,我在 c++ 程序中遇到错误。错误信息是:
error:Please initialize the log4cxx system properly
请帮忙解决,
提前致谢。
AFAIR 您必须在程序开始时配置 log4cxx 系统,例如使用Apache log4cxx 简介BasicConfigurator
中所示的a :
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
LoggerPtr logger(Logger::getLogger("MyApp"));
int main(int argc, char **argv)
{
// Set up a simple configuration that logs on the console.
BasicConfigurator::configure();
LOG4CXX_INFO(logger, "Entering application.");
// ...
return 0;
}
HTH 马丁