log/src/main/java/org/apache/karaf/log/core/internal/LogServiceLog4j2XmlImpl.java [207:252]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static Document loadConfig(Path path) throws Exception {
        try (InputStream is = Files.newInputStream(path)) {
            return loadConfig(path.toString(), is);
        }
    }

    static Document loadConfig(String id, InputStream is) throws ParserConfigurationException, SAXException, IOException {
        final InputSource source = new InputSource(is);
        source.setPublicId(id);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);
        factory.setExpandEntityReferences(false);

        setFeature(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true);
        setFeature(factory, "http://xml.org/sax/features/external-general-entities", false);
        setFeature(factory, "http://xml.org/sax/features/external-parameter-entities", false);
        setFeature(factory, "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        setFeature(factory, "http://apache.org/xml/features/xinclude/fixup-base-uris", true);
        setFeature(factory, "http://apache.org/xml/features/xinclude/fixup-language", true);
        tryCall(() -> factory.setXIncludeAware(true));
        DocumentBuilder documentBuilder = factory.newDocumentBuilder();
        return documentBuilder.parse(source);
    }

    private static void setFeature(DocumentBuilderFactory factory, String name, boolean b) {
        tryCall(() -> factory.setFeature(name, b));
    }

    interface RunnableWithException {
        void run() throws Exception;
    }

    private static void tryCall(RunnableWithException c) {
        try {
            c.run();
        } catch (Exception e) {
            // Ignore
        }
    }

    private Map<String, Element> getLoggers(Document doc) {
        Map<String, Element> loggers = new TreeMap<>();
        Element docE = doc.getDocumentElement();
        if (!ELEMENT_CONFIGURATION.equals(docE.getLocalName())) {
            throw new IllegalArgumentException("Xml root document should be " + ELEMENT_CONFIGURATION);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



log/src/main/java/org/apache/karaf/log/core/internal/LogServiceLogbackXmlImpl.java [201:246]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static Document loadConfig(Path path) throws Exception {
        try (InputStream is = Files.newInputStream(path)) {
            return loadConfig(path.toString(), is);
        }
    }

    static Document loadConfig(String id, InputStream is) throws ParserConfigurationException, SAXException, IOException {
        final InputSource source = new InputSource(is);
        source.setPublicId(id);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);
        factory.setExpandEntityReferences(false);

        setFeature(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true);
        setFeature(factory, "http://xml.org/sax/features/external-general-entities", false);
        setFeature(factory, "http://xml.org/sax/features/external-parameter-entities", false);
        setFeature(factory, "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        setFeature(factory, "http://apache.org/xml/features/xinclude/fixup-base-uris", true);
        setFeature(factory, "http://apache.org/xml/features/xinclude/fixup-language", true);
        tryCall(() -> factory.setXIncludeAware(true));
        DocumentBuilder documentBuilder = factory.newDocumentBuilder();
        return documentBuilder.parse(source);
    }

    private static void setFeature(DocumentBuilderFactory factory, String name, boolean b) {
        tryCall(() -> factory.setFeature(name, b));
    }

    interface RunnableWithException {
        void run() throws Exception;
    }

    private static void tryCall(RunnableWithException c) {
        try {
            c.run();
        } catch (Exception e) {
            // Ignore
        }
    }

    private Map<String, Element> getLoggers(Document doc) {
        Map<String, Element> loggers = new TreeMap<>();
        Element docE = doc.getDocumentElement();
        if (!ELEMENT_CONFIGURATION.equals(docE.getLocalName())) {
            throw new IllegalArgumentException("Xml root document should be " + ELEMENT_CONFIGURATION);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



