blob: 1ea866730009ff6606bfa82e4a3abf39f86495e9 [file] [log] [blame]
Jeff Thompsone2cd5872013-09-19 15:53:29 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
5 * @author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#include "logging.hpp"
10
11#ifdef HAVE_LOG4CXX
12
13#include <log4cxx/logger.h>
14#include <log4cxx/basicconfigurator.h>
15#include <log4cxx/consoleappender.h>
16#include <log4cxx/patternlayout.h>
17#include <log4cxx/level.h>
18#include <log4cxx/propertyconfigurator.h>
19#include <log4cxx/defaultconfigurator.h>
20#include <log4cxx/helpers/exception.h>
21using namespace log4cxx;
22using namespace log4cxx::helpers;
23
24#include <unistd.h>
25
26void
27INIT_LOGGERS ()
28{
29 static bool configured = false;
30
31 if (configured) return;
32
33 if (access ("log4cxx.properties", R_OK)==0)
34 PropertyConfigurator::configureAndWatch ("log4cxx.properties");
35 else
36 {
37 PatternLayoutPtr layout (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n"));
38 ConsoleAppenderPtr appender (new ConsoleAppender (layout));
39
40 BasicConfigurator::configure( appender );
41 Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ());
42 }
43
44 configured = true;
45}
46
47#endif