Package org.apache.log4j

Examples of org.apache.log4j.ConsoleAppender


      LOG.info("Using custom logging settings from file " + log4jPropFile);
    }
    else
    {
      PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
      ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

      Logger.getRootLogger().removeAllAppenders();
      Logger.getRootLogger().addAppender(defaultAppender);

      LOG.info("Using default logging settings");
View Full Code Here


          LOG.info("Using custom logging settings from file " + log4jPropFile);
      }
      else
      {
          PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c} %m%n");
          ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);

          Logger.getRootLogger().removeAllAppenders();
          Logger.getRootLogger().addAppender(defaultAppender);

          LOG.info("Using default logging settings");
View Full Code Here

  }
 
  static public void attachTemporaryConsoleAppender(LoggerRepository repository) {
    Logger ll = repository.getLogger(Constants.LOG4J_PACKAGE_NAME);
   
    ConsoleAppender appender = new ConsoleAppender();
    appender.setLayout(
      new PatternLayout("LOG4J-INTERNAL: %d %level [%t] %c#%M:%L)- %m%n"));
    appender.setName(Constants.TEMP_CONSOLE_APPENDER_NAME);
    appender.activateOptions();
    ll.addAppender(appender);
  }
View Full Code Here

  }

  static public void detachTemporaryConsoleAppender(LoggerRepository repository, List errorList) {

    Logger ll = repository.getLogger(Constants.LOG4J_PACKAGE_NAME);
    ConsoleAppender consoleAppender =
      (ConsoleAppender) ll.getAppender(Constants.TEMP_CONSOLE_APPENDER_NAME);
    if (consoleAppender == null) {
      String errMsg =
        "Could not find appender " + Constants.TEMP_LIST_APPENDER_NAME;
      errorList.add(new ErrorItem(errMsg));
      return;
    }
    consoleAppender.close();
    ll.removeAppender(consoleAppender);
  }
View Full Code Here

    private org.apache.log4j.Logger getFallabckLogger() {
        final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("OpenEJB.logging");

        final SimpleLayout simpleLayout = new SimpleLayout();
        final ConsoleAppender newAppender = new ConsoleAppender(simpleLayout);
        logger.addAppender(newAppender);
        return logger;
    }
View Full Code Here

        assertTrue("Audit file wasn't written to", log.length() > 0);
    }

    protected void setUp() throws Exception {
        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%p [%t] %m %n")));
        Logger.getRootLogger().setLevel(Level.DEBUG);
        kernel = KernelFactory.newInstance().createKernel("test.kernel");
        kernel.boot();

        GBeanData gbean;
View Full Code Here

        return new AbstractName(new Artifact("test", "foo", "1", "car"), names, objectName);
    }

    protected void setUp() throws Exception {
        Logger.getRootLogger().setLevel(Level.WARN);
        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%p [%t] %m %n")));
        super.setUp();
        kernel = KernelFactory.newInstance().createKernel(DOMAIN);
        kernel.boot();

        ClassLoader classLoader = getClass().getClassLoader();
View Full Code Here

        }
    }

    protected void setUp() throws Exception {
        super.setUp();
        Logger.getRootLogger().addAppender(new ConsoleAppender(new PatternLayout("%p [%t] %m %n")));
        Logger.getRootLogger().setLevel(Level.DEBUG);
        realKernel = KernelFactory.newInstance().createKernel("test");
        realKernel.boot();
        kernel = kernelWraper.wrap(realKernel);
    }
View Full Code Here

      Environment.getenv();
      if(Environment.debugging) {
        Logger rootLogger = Logger.getRootLogger();
        rootLogger.setLevel(Level.WARN);

        ConsoleAppender consoleAppender = null;
        for(Enumeration<Appender> e = (Enumeration<Appender>)rootLogger.getAllAppenders();
            e.hasMoreElements();) {
       
          Appender a = e.nextElement();
          if(a instanceof ConsoleAppender) {
            consoleAppender = (ConsoleAppender)a;
            break;
          }
        }
        if(consoleAppender != null) {
          Layout layout = consoleAppender.getLayout();
          if(layout instanceof PatternLayout) {
            PatternLayout consoleLayout = (PatternLayout)layout;
            consoleLayout.setConversionPattern("%d %-5p [%t] %l: %m%n");
          }
        }
View Full Code Here

      Environment.getenv();
      if(Environment.debugging) {
        Logger rootLogger = Logger.getRootLogger();
        rootLogger.setLevel(Level.WARN);

        ConsoleAppender consoleAppender = null;
        for(Enumeration<Appender> e = (Enumeration<Appender>)rootLogger.getAllAppenders();
            e.hasMoreElements();) {
       
          Appender a = e.nextElement();
          if(a instanceof ConsoleAppender) {
            consoleAppender = (ConsoleAppender)a;
            break;
          }
        }
        if(consoleAppender != null) {
          Layout layout = consoleAppender.getLayout();
          if(layout instanceof PatternLayout) {
            PatternLayout consoleLayout = (PatternLayout)layout;
            consoleLayout.setConversionPattern("%d %-5p [%t] %l: %m%n");
          }
        }
View Full Code Here

TOP

Related Classes of org.apache.log4j.ConsoleAppender

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.