Package java.util.logging

Examples of java.util.logging.Formatter


            // the formatter.format will fail with NullPointerException (#12588)
            if (record.getMessage() == null) {
                record.setMessage("");
            }

            Formatter formatter = getFormatter();
            String msg = formatter.format(record);

            addRow(record.getLevel(), msg);
        }
View Full Code Here


     *=================================*/

    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

        setLevel((level == null) ? Level.OFF : Level.parse(level));
    }

    @Override
    public void publish(LogRecord record) {
        Formatter formatter =
            LoggerUtils.formatterMap.get(Thread.currentThread());
        if (formatter != null) {
            setFormatter(formatter);
        }
        super.publish(record);
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        handler.publicSetOutputStream(out);
        handler.publish(r);
        handler.close();
        String msg = new String(out.toByteArray());
        Formatter f = handler.getFormatter();
        assertEquals(msg, f.getHead(handler) + f.format(r) + f.getTail(handler));
        assertFileContent(HOMEPATH, "setoutput.log", handler.getFormatter(), null);
    }
View Full Code Here

     *=================================*/

    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

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

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

                  setParameter(currentElement, beanProps);
               }
               // Set appender layout
               else if (currentElement.getTagName().equals(LAYOUT_TAG))
               {
                  Formatter format = parseLayout(currentElement);
                  appender.setFormatter(format);
               }
               // Add filters
               else if (currentElement.getTagName().equals(FILTER_TAG))
               {
View Full Code Here

      String className = subst(layout_element.getAttribute(CLASS_ATTR));
      debug("Parsing layout of class: \"" + className + "\"");
      try
      {
         Object instance = instantiateByClassName(className, Formatter.class, null);
         Formatter layout = (Formatter) instance;
         Properties beanProps = new Properties();

         NodeList params = layout_element.getChildNodes();
         final int length = params.getLength();
View Full Code Here

    * Most subclasses of WriterHandler will need to
    * override this method.
    */
   protected void subPublish(LogRecord record)
   {
      Formatter fmt = getFormatter();
      String msg = fmt.format(record);
      synchronized (this)
      {
         try
         {
            msgWriter.write(msg);
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.