Package java.util.logging

Examples of java.util.logging.Formatter


  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


              Date date = new Date();
                 dateFormat.format(date);

    // Output the formatted data to the file
                
                 Formatter f = getFormatter();

                 messages.add(f.format(record));

                 if (messages.size() > 20)
                 {
                     messages.remove(0);
                 }
View Full Code Here

        Logger logger = Logger.getLogger("");
      resetLogger();
        // configure console logger
        for (Handler handler : logger.getHandlers()) {
            if (handler instanceof ConsoleHandler) {
                Formatter formatter = handler.getFormatter();
                if (formatter instanceof SimpleFormatter) {
                    /* DGF Nobody likes the SimpleFormatter; surely they
                     * wanted our terse formatter instead.
                     * Furthermore, we all want DEBUG/INFO on stdout and WARN/ERROR on stderr */
                    Level originalLevel = handler.getLevel();
View Full Code Here

    String formatterClassName =
      p.getProperty("handler.formatter.class",
        "org.mitre.sim.util.BasicFormatter");
    String formatterFormat = p.getProperty("handler.formatter.format");
    Formatter formatter = null;
    try {
      formatter = (Formatter)Class.forName(formatterClassName).newInstance();
    }
    catch (Throwable t) {
      formatter = new BasicFormatter();
View Full Code Here

        String logfileName = ConnectionManager.getModificationLogFileName( connection );
        try
        {
            FileHandler fileHandler = new FileHandler( logfileName, 100000, 10, true );
            fileHandlers.put( connection.getId(), fileHandler );
            fileHandler.setFormatter( new Formatter()
            {
                public String format( LogRecord record )
                {
                    return record.getMessage();
                }
View Full Code Here

            record.setParameters(params);
        }
        record.setResourceBundle(logger.getResourceBundle());
        record.setSourceClassName(sourceClassName);

        Formatter formatter = new SimpleFormatter();

        return context + " - " + formatter.formatMessage(record);
    }
View Full Code Here

        String logfileName = ConnectionManager.getModificationLogFileName( connection.getName() );
        try
        {
            fileHandler = new FileHandler( logfileName, 100000, 10, true );
            fileHandler.setFormatter( new Formatter()
            {
                public String format( LogRecord record )
                {
                    return record.getMessage();
                }
View Full Code Here

            record.setParameters(params);
        }
        record.setResourceBundle(logger.getResourceBundle());
        record.setSourceClassName(sourceClassName);
        Formatter formatter = new SimpleFormatter();
       
        return formatter.formatMessage(record);
    }
View Full Code Here

  }

  public void testClose() {
    Filter filter = handler.getFilter();
    Formatter formatter = handler.getFormatter();
    writer.getBuffer().setLength(0);
    handler.close();
    assertEquals(writer.toString(), "close");
    assertEquals(handler.getFilter(), filter);
    assertEquals(handler.getFormatter(), formatter);
View Full Code Here

    assertFalse(handler.isLoggable(new LogRecord(Level.SEVERE, "test")));
  }

  public void testFlush() {
    Filter filter = handler.getFilter();
    Formatter formatter = handler.getFormatter();
    writer.getBuffer().setLength(0);
    handler.flush();
    assertEquals(writer.toString(), "flush");
    assertEquals(handler.getFilter(), filter);
    assertEquals(handler.getFormatter(), formatter);
View Full Code Here

TOP

Related Classes of java.util.logging.Formatter

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.