diff --git a/backends/template/main.cpp b/backends/template/main.cpp index 44fc86237e1ae10824de23377be3b22f6eebd97d..595ce42d19cde6e8e3ae865758d6d664992b4eb7 100644 --- a/backends/template/main.cpp +++ b/backends/template/main.cpp @@ -1,6 +1,7 @@ // Transport includes #include "transport/config.h" #include "transport/networkplugin.h" +#include "transport/logging.h" // Swiften #include "Swiften/Swiften.h" @@ -11,24 +12,13 @@ #include "sys/wait.h" #include "sys/signal.h" -// Log4cxx -#include "log4cxx/logger.h" -#include "log4cxx/consoleappender.h" -#include "log4cxx/patternlayout.h" -#include "log4cxx/propertyconfigurator.h" -#include "log4cxx/helpers/properties.h" -#include "log4cxx/helpers/fileinputstream.h" -#include "log4cxx/helpers/transcoder.h" - // Boost #include using namespace boost::filesystem; using namespace boost::program_options; using namespace Transport; -// log4cxx main logger -using namespace log4cxx; -static LoggerPtr logger = log4cxx::Logger::getLogger("Backend Template"); +DEFINE_LOGGER(logger, "Backend Template"); // eventloop Swift::SimpleEventLoop *loop_; @@ -147,30 +137,7 @@ int main (int argc, char* argv[]) { return 1; } - if (CONFIG_STRING(&config, "logging.backend_config").empty()) { - LoggerPtr root = log4cxx::Logger::getRootLogger(); -#ifndef _MSC_VER - root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n"))); -#else - root->addAppender(new ConsoleAppender(new PatternLayout(L"%d %-5p %c: %m%n"))); -#endif - } - else { - log4cxx::helpers::Properties p; - log4cxx::helpers::FileInputStream *istream = new log4cxx::helpers::FileInputStream(CONFIG_STRING(&config, "logging.backend_config")); - p.load(istream); - LogString pid, jid; - log4cxx::helpers::Transcoder::decode(boost::lexical_cast(getpid()), pid); - log4cxx::helpers::Transcoder::decode(CONFIG_STRING(&config, "service.jid"), jid); -#ifdef _MSC_VER - p.setProperty(L"pid", pid); - p.setProperty(L"jid", jid); -#else - p.setProperty("pid", pid); - p.setProperty("jid", jid); -#endif - log4cxx::PropertyConfigurator::configure(p); - } + Logging::initBackendLogging(&config); Swift::SimpleEventLoop eventLoop; loop_ = &eventLoop;