使用log4cxx时在c ++程序中出现错误。错误消息是:

error:Please initialize the log4cxx system properly


请协助解决,

提前致谢。

最佳答案

之后,您必须在程序开始时配置log4cxx系统,例如使用此Short introduction to Apache log4cxx中所示的BasicConfigurator

#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
马丁

10-06 04:10