All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logging.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
9 #include "common.hpp"
10 
11 #include "logging.hpp"
12 
13 #ifdef NDN_CPP_HAVE_LOG4CXX
14 
15 #include <log4cxx/logger.h>
16 #include <log4cxx/basicconfigurator.h>
17 #include <log4cxx/consoleappender.h>
18 #include <log4cxx/patternlayout.h>
19 #include <log4cxx/level.h>
20 #include <log4cxx/propertyconfigurator.h>
21 #include <log4cxx/defaultconfigurator.h>
22 #include <log4cxx/helpers/exception.h>
23 using namespace log4cxx;
24 using namespace log4cxx::helpers;
25 
26 #include <unistd.h>
27 
28 void
30 {
31  static bool configured = false;
32 
33  if (configured) return;
34 
35  if (access("log4cxx.properties", R_OK)==0)
36  PropertyConfigurator::configureAndWatch("log4cxx.properties");
37  else
38  {
39  PatternLayoutPtr layout (new PatternLayout("%d{HH:mm:ss} %p %c{1} - %m%n"));
40  ConsoleAppenderPtr appender(new ConsoleAppender(layout));
41 
42  BasicConfigurator::configure( appender );
43  Logger::getRootLogger()->setLevel(log4cxx::Level::getInfo());
44  }
45 
46  configured = true;
47 }
48 
49 #endif
#define INIT_LOGGERS(x)
Definition: logging.hpp:57