Package org.apache.log4j.xml

Examples of org.apache.log4j.xml.DOMConfigurator


        } 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

        } 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

        } 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

      else
      {
        //slightly ugly hack: record a good default configuration as a String in this class, and load that
        //emulating DOMConfigurator.configure(Reader)
        //see http://svn.apache.org/viewvc/logging/log4j/branches/v1_2-branch/src/java/org/apache/log4j/xml/DOMConfigurator.java?revision=311462&view=markup
        new DOMConfigurator().doConfigure(new StringReader(DEFAULT_LOG4J_CONFIG), org.apache.log4j.LogManager.getLoggerRepository());
      }
    }
    //setup the logger for this class
    logger = Logger.getLogger(ApplicationSetup.class);
    //setup default filename
View Full Code Here

            newElement.appendChild( newNode );
        }

        document.appendChild( newElement );

        /**
         * Copied from org.apache.log4j.xml.DomConfigurator configure().
         * We want our own hierarchy to be configured, so we shall
         * be a bit more elaborate then just calling configure().
         */
        final DOMConfigurator domConfigurator = new DOMConfigurator();
        domConfigurator.doConfigure( newElement, m_hierarchy );
    }
View Full Code Here

                final ClassLoader current = SecurityActions.getThreadContextClassLoader();
                final LogContext old = LoggingExtension.THREAD_LOCAL_CONTEXT_SELECTOR.getAndSet(CONTEXT_LOCK, logContext);
                try {
                    SecurityActions.setThreadContextClassLoader(classLoader);
                    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, ENCODING));
                        new org.apache.log4j.PropertyConfigurator().doConfigure(properties, org.apache.log4j.JBossLogManagerFacade.getLoggerRepository(logContext));
                    }
View Full Code Here

   * @param prefix
   */
  public Log4JConfigurator(String prefix) {
    this.prefix = prefix;
    props.setProperty(CONTEXT_ROOT_VARIABLE, prefix);
    domConfig = new DOMConfigurator() {

      /*
       * (non-Javadoc)
       *
       * @see org.apache.log4j.xml.DOMConfigurator#subst(java.lang.String)
View Full Code Here

   * Load the log4j xml configuration file.  If the user does not supply a
   * configuration file load the sample configuration.
   * @param configFile The configuration filename.
   */
  private static void loadConfiguration(String configFile) {
    DOMConfigurator domConfigurator = new DOMConfigurator();
    if (configFile == null) {
      ClassLoader loader = ClassLoader.getSystemClassLoader ();   
      String resourceName = "com/volantis/mcs/cli/"
  + "marinerSocketServer-log4j.xml";
      try {
  InputStream inputStream = loader.getResourceAsStream (resourceName);
  if (inputStream != null) {
    domConfigurator.doConfigure(inputStream, cat.getDefaultHierarchy());
  } else {
    doError("An error occured loading the default configuration");
  }
      }
      catch (Exception e) {
  doError("An error occured loading the default configuration");
      }
    } else {
      try {
  FileInputStream fis = new FileInputStream(configFile);
  domConfigurator.doConfigure(fis, cat.getDefaultHierarchy());
      }
      catch (FileNotFoundException e) {
  doError("Configuration File not found: " + configFile);
      }
      catch (Exception 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.