Package java.util.logging

Examples of java.util.logging.ConsoleHandler


  @Test
  public void testAllKindsOfComponents() throws Exception {
    final List<LogRecord> records = new ArrayList<LogRecord>();

    // Tell the logger to log everything
    ConsoleHandler handler = (ConsoleHandler) LogManager.getLogManager().getLogger("")
            .getHandlers()[0];
    java.util.logging.Level oldLevel = handler.getLevel();
    handler.setLevel(Level.ALL);
    handler.setFilter(new Filter() {
      public boolean isLoggable(LogRecord record) {
        records.add(record);
        return true;
      }
    });

    try {
      JCas jcas = JCasFactory.createJCas();

      createReader(LoggingCasCollectionReader.class).hasNext();
      assertLogDone(records);

      createReader(LoggingJCasCollectionReader.class).hasNext();
      assertLogDone(records);

      // createFlowControllerDescription(LoggingJCasFlowController.class).
      // assertLogDone(records);

      createEngine(LoggingCasAnnotator.class).process(jcas.getCas());
      assertLogDone(records);

      createEngine(LoggingJCasAnnotator.class).process(jcas);
      assertLogDone(records);

      createEngine(LoggingCasConsumer.class).process(jcas.getCas());
      assertLogDone(records);

      createEngine(LoggingJCasConsumer.class).process(jcas);
      assertLogDone(records);

      createEngine(LoggingCasMultiplier.class).process(jcas.getCas());
      assertLogDone(records);

      createEngine(LoggingJCasMultiplier.class).process(jcas);
      assertLogDone(records);
    } finally {
      if (oldLevel != null) {
        handler.setLevel(oldLevel);
        handler.setFilter(null);
      }
    }
  }
View Full Code Here


        }
    }

    private Logger getFallabckLogger() {
        java.util.logging.Logger logger = Logger.getLogger("OpenEJB.logging");
        ConsoleHandler consoleHandler = new ConsoleHandler();
        consoleHandler.setFormatter(new SimpleFormatter());
        logger.addHandler(consoleHandler);
        return logger;
    }
View Full Code Here

    /*=================================
          Main class implementation
     *=================================*/

    public static void main(String[] args) throws Exception {
        Handler fh = new ConsoleHandler();
        fh.setLevel(Level.FINEST);
        fh.setFormatter(new Formatter() {
            @Override
            public String format(LogRecord record) {
                String message = formatMessage(record);
                String throwable = "";
                if (record.getThrown() != null) {
View Full Code Here

  private static ConsoleHandler remoteMethodHandler;

  private static synchronized StreamHandler getStreamHandler() {
    if (remoteMethodHandler == null) {
      remoteMethodHandler = new ConsoleHandler();
      remoteMethodHandler.setFormatter(new Formatter() {
        @Override
        public String format(LogRecord record) {
          return record.getMessage() + "\n";
        }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);
    }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);
    }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);
    }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);
    }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);

        pstream = new PrintStream(outStream, true);
        writer = new FileWriter(basedir + "/build/test-results/run-junit-embed.txt", true);
    }
View Full Code Here

        Handler handler = new StreamHandler(outStream, new SimpleFormatter());
        logger0.addHandler(handler);
        logger0.setUseParentHandlers(false);
        logger0.setLevel(Level.INFO);
        logger1.setUseParentHandlers(false);
        logger1.addHandler(new ConsoleHandler());
        logger1.setLevel(Level.WARNING);

        writer = new FileWriter(basedir + "/build/test-results/run-junit-embed.txt", true);
    }
View Full Code Here

TOP

Related Classes of java.util.logging.ConsoleHandler

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.