blob: 647463afb996c6c02c8fafbd16fdcfad1247a303 [file] [log] [blame]
#include "com/foo/config.h"
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/logmanager.h>
namespace com { namespace foo {
auto getLogger(const std::string& name) -> LoggerPtr {
using namespace log4cxx;
static struct log4cxx_initializer {
log4cxx_initializer() {
if (PropertyConfigurator::configure("MyApp.properties") == spi::ConfigurationStatus::NotConfigured)
BasicConfigurator::configure(); // Send events to the console
}
~log4cxx_initializer() {
LogManager::shutdown();
}
} initAndShutdown;
return name.empty()
? LogManager::getRootLogger()
: LogManager::getLogger(name);
}
} } // namespace com::foo