Package org.apache.log4j.xml

Examples of org.apache.log4j.xml.DOMConfigurator


                    if (LOG4J_PROPERTIES.equals(fileName) || LOG4J_XML.equals(fileName) || JBOSS_LOG4J_XML.equals(fileName)) {
                        final ClassLoader current = SecurityActions.getThreadContextClassLoader();
                        try {
                            SecurityActions.setThreadContextClassLoader(module.getClassLoader());
                            if (LOG4J_XML.equals(fileName) || JBOSS_LOG4J_XML.equals(fileName)) {
                                new DOMConfigurator().doConfigure(configStream, org.apache.log4j.JBossLogManagerFacade.getLoggerRepository(logContext));
                            } else {
                                final Properties properties = new Properties();
                                properties.load(new InputStreamReader(configStream, "utf-8"));
                                new org.apache.log4j.PropertyConfigurator().doConfigure(properties, org.apache.log4j.JBossLogManagerFacade.getLoggerRepository(logContext));
                            }
View Full Code Here


    /**
     * Static method to change the Log4j config globally.
     * @param xmlConfig The text of a Log4j config file.
     */
    public static void configure(String xmlConfig) {
        DOMConfigurator configurator = new DOMConfigurator();
        StringReader sr = new StringReader(xmlConfig.trim());
        configurator.doConfigure(sr, LogManager.getLoggerRepository());
    }
View Full Code Here

            }
            if (log4jConfigLocation.endsWith(".xml")) {
                if (log4jConfigLocation.startsWith("classpath:")) {
                    log4jConfigLocation = log4jConfigLocation.replaceFirst("classpath:", "");
                    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(log4jConfigLocation);
                    new DOMConfigurator().doConfigure(is, LogManager.getLoggerRepository());
                } else {
                    DOMConfigurator.configureAndWatch(log4jConfigLocation);
                }
            } else if (log4jConfigLocation.endsWith(".properties")) {
                if (log4jConfigLocation.startsWith("classpath:")) {
View Full Code Here

        } catch (IOException e) {
            log.warn("Could not determine content type from URL; ignoring", e);
        }
        if (contentType != null) {
            if (contentType.toLowerCase().endsWith("/xml")) {
                return new DOMConfigurator();
            }
        }

        // Check thr file name
        String filename = url.getFile().toLowerCase();
        if (filename.endsWith(".xml")) {
            return new DOMConfigurator();
        } else if (filename.endsWith(".properties")) {
            return new PropertyConfigurator();
        }

        // Check for <?xml in content
        if (connection != null) {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    String head = reader.readLine();
                    if (head.startsWith("<?xml")) {
                        return new DOMConfigurator();
                    }
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
View Full Code Here

            }
            if (log4jConfigLocation.endsWith(".xml")) {
                if (log4jConfigLocation.startsWith("classpath:")) {
                    log4jConfigLocation = log4jConfigLocation.replaceFirst("classpath:", "");
                    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(log4jConfigLocation);
                    new DOMConfigurator().doConfigure(is, LogManager.getLoggerRepository());
                } else {
                    DOMConfigurator.configureAndWatch(log4jConfigLocation);
                }
            } else if (log4jConfigLocation.endsWith(".properties")) {
                if (log4jConfigLocation.startsWith("classpath:")) {
View Full Code Here

/* 86 */       e.printStackTrace();
/* 87 */       usage("Could not interpret port number [" + portStr + "].");
/*    */     }
/*    */
/* 90 */     if (configFile.endsWith(".xml")) {
/* 91 */       new DOMConfigurator(); DOMConfigurator.configure(configFile);
/*    */     } else {
/* 93 */       new PropertyConfigurator(); PropertyConfigurator.configure(configFile);
/*    */     }
/*    */   }
View Full Code Here

    String str3 = paramArrayOfString[2];
    String str4 = paramArrayOfString[3];
    String str5 = paramArrayOfString[4];
    if (str5.endsWith(".xml"))
    {
      new DOMConfigurator();
      DOMConfigurator.configure(str5);
    }
    else
    {
      new PropertyConfigurator();
View Full Code Here

        } catch (IOException e) {
            log.warn("Could not determine content type from URL; ignoring", e);
        }
        if (contentType != null) {
            if (contentType.toLowerCase().endsWith("/xml")) {
                return new DOMConfigurator();
            }
        }

        // Check thr file name
        String filename = url.getFile().toLowerCase();
        if (filename.endsWith(".xml")) {
            return new DOMConfigurator();
        } else if (filename.endsWith(".properties")) {
            return new PropertyConfigurator();
        }

        // Check for <?xml in content
        if (connection != null) {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    String head = reader.readLine();
                    if (head.startsWith("<?xml")) {
                        return new DOMConfigurator();
                    }
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
View Full Code Here

        } catch (IOException e) {
            log.warn("Could not determine content type from URL; ignoring", e);
        }
        if (contentType != null) {
            if (contentType.toLowerCase().endsWith("/xml")) {
                return new DOMConfigurator();
            }
        }

        // Check thr file name
        String filename = url.getFile().toLowerCase();
        if (filename.endsWith(".xml")) {
            return new DOMConfigurator();
        } else if (filename.endsWith(".properties")) {
            return new PropertyConfigurator();
        }

        // Check for <?xml in content
        if (connection != null) {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    String head = reader.readLine();
                    if (head.startsWith("<?xml")) {
                        return new DOMConfigurator();
                    }
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
View Full Code Here

            InputStream log4JConfig = config.getServletContext()
                    .getResourceAsStream(log4jFile);
            Document doc = DocumentBuilderFactory.newInstance()
                    .newDocumentBuilder().parse(log4JConfig);

            DOMConfigurator conf = new DOMConfigurator();
            conf.doConfigure(doc.getDocumentElement(), hierarchy);
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.log4j.xml.DOMConfigurator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.