in src/main/cpp/domconfigurator.cpp [782:852]
spi::ConfigurationStatus DOMConfigurator::doConfigure(const File& filename, spi::LoggerRepositoryPtr repository1)
{
repository1->setConfigured(true);
m_priv->repository = repository1;
LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
msg.append(filename.getPath());
msg.append(LOG4CXX_STR("..."));
LogLog::debug(msg);
m_priv->loggerFactory = std::make_shared<DefaultLoggerFactory>();
Pool p;
apr_file_t* fd;
log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
if (rv != APR_SUCCESS)
{
// There is not technically an exception thrown here, but this behavior matches
// what the PropertyConfigurator does
IOException io(rv);
LogString msg2(LOG4CXX_STR("Could not read configuration file ["));
msg2.append(filename.getPath());
msg2.append(LOG4CXX_STR("]. "));
LOG4CXX_DECODE_CHAR(msg, io.what());
msg2.append(msg);
LogLog::error(msg2);
return spi::ConfigurationStatus::NotConfigured;
}
else
{
apr_xml_parser* parser = NULL;
apr_xml_doc* doc = NULL;
LogString debugMsg = LOG4CXX_STR("Loading configuration file [")
+ filename.getPath() + LOG4CXX_STR("].");
LogLog::debug(debugMsg);
rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000);
if (rv != APR_SUCCESS)
{
char errbuf[2000];
char errbufXML[2000];
LogString msg2(LOG4CXX_STR("Error parsing file ["));
msg2.append(filename.getPath());
msg2.append(LOG4CXX_STR("], "));
apr_strerror(rv, errbuf, sizeof(errbuf));
LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
msg2.append(lerrbuf);
if (parser)
{
apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML));
LOG4CXX_DECODE_CHAR(lerrbufXML, std::string(errbufXML));
msg2.append(lerrbufXML);
}
LogLog::error(msg2);
return spi::ConfigurationStatus::NotConfigured;
}
else
{
AppenderMap appenders;
CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
parse(p, utf8Decoder, doc->root, doc, appenders);
}
}
return spi::ConfigurationStatus::Configured;
}