Apache Log4cxx
Version 1.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
com/foo/config2.cpp
This file is a simplified example of encapsulated Log4cxx configuration.
#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
basicconfigurator.h
log4cxx::BasicConfigurator::configure
static void configure(const LayoutPtr &layout=LayoutPtr())
Add a ConsoleAppender that formats output using layout to the root logger.
log4cxx::LogManager::getRootLogger
static LoggerPtr getRootLogger()
Retrieve the root logger from the LoggerRepository.
log4cxx::LogManager::getLogger
static LoggerPtr getLogger(const std::string &name)
Retrieve the name Logger instance from the LoggerRepository using the default factory to create it if...
log4cxx::LogManager::shutdown
static void shutdown()
Safely close and remove all appenders in all loggers including the root logger.
log4cxx::PropertyConfigurator::configure
static spi::ConfigurationStatus configure(const File &configFilename)
Read configuration options from file configFilename.
logmanager.h
log4cxx::spi::ConfigurationStatus::NotConfigured
@ NotConfigured
Definition
configurator.h:33
log4cxx
Definition
configuration.h:26
propertyconfigurator.h
Generated by
1.17.0 on
SITE_PUBLISHED_DATE
Copyright © 2017-2026
Apache Software Foundation
. Apache, Chainsaw, log4cxx, Log4j, Log4net, log4php and the Apache logo are
trademarks or registered trademarks
of The Apache Software Foundation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Privacy Policy
.