Apache Log4cxx: auto-configured.cpp (original) (raw)

This is an example of logging in static initialization code and using the current module name (auto-configured) to select the Log4cxx configuration file. In this example Log4cxx is configured by loading auto-configured.xml. The function com::foo::getLogger(), which is called during initialization, is implemented in the com/foo/config4.cpp file.

#include "com/foo/config.h"

auto rootLogger = com::foo::getLogger();

struct ExampleStaticData {

ExampleStaticData() {

LOG4CXX_DEBUG(rootLogger, "static initializer message");

}

} static_object;

int main() {

LOG4CXX_INFO(rootLogger, "main function message");

return EXIT_SUCCESS;

}

#define LOG4CXX_INFO(logger, message)

Add a new logging event containing message to attached appender(s) if logger is enabled for INFO even...

Definition log4cxx/logger.h:2386

#define LOG4CXX_DEBUG(logger, message)

Add a new logging event containing message to attached appender(s) if logger is enabled for DEBUG eve...

Definition log4cxx/logger.h:2300