Package java.util.logging

Examples of java.util.logging.Formatter


               // Handler[] tmpHandlers = defLogger.getHandlers();
               // Handler[] refHandlers = new Handler[tmpHandlers.length];
               Handler[] refHandlers = defLogger.getHandlers();
               for (int i=0; i < refHandlers.length; i++) {
                  refHandlers[i].setLevel(Level.FINEST);
                  Formatter formatter = refHandlers[i].getFormatter();
                  if (formatter instanceof XbFormatter) {
                     XbFormatter xb = (XbFormatter)formatter;
                     xb.setGlobal(this);
                  }
               }
View Full Code Here


    }
    if(outHandlerList.size() == 0){
        outHandlerList.add(new ConsoleHandler());
    }
    String loggingFormat = getString("loggings.format", "java.util.logging.XMLFormatter");
    Formatter format=null;
    try {
      Class c = Class.forName(loggingFormat);
      if(Formatter.class.isAssignableFrom(c)){
        try {
          format=(Formatter)c.newInstance();
View Full Code Here

    }   
   
    private Formatter makeFormatter(final String name) {
        if (name == null) return null;
       
        Formatter f = null;
        try {
            final Class<?> c = Class.forName(name);
            f = (Formatter)c.newInstance();
        } catch (final Exception e) {
            f = new SimpleFormatter();
View Full Code Here

    }   
   
    private Formatter makeFormatter(final String name) {
        if (name == null) return null;
       
        Formatter f = null;
        try {
            final Class<?> c = Class.forName(name);
            f = (Formatter)c.newInstance();
        } catch (final Exception e) {
            f = new SimpleFormatter();
View Full Code Here

    public final synchronized String getLog(final boolean reversed, int lineCount) {
       
        if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;
       
        final StringBuilder logMessages = new StringBuilder(this.count*40);
        final Formatter logFormatter = getFormatter();
       
        try {
            final int theStart = (reversed)?this.start+this.count-1:this.start;
            LogRecord record=null;
            for (int i = 0; i < lineCount; i++) {
                final int ix = (reversed) ?
                    Math.abs((theStart-i)%this.buffer.length) :
                    (theStart+i)%this.buffer.length;
                record = this.buffer[ix];
                logMessages.append(logFormatter.format(record));
            }
            return logMessages.toString();
        } catch (final Exception ex) {
            // We don't want to throw an exception here, but we
            // report the exception to any registered ErrorManager.
View Full Code Here

    public final synchronized String[] getLogLines(final boolean reversed, int lineCount) {
       
        if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;
       
        final List<String> logMessages = new ArrayList<String>(this.count);
        final Formatter logFormatter = getFormatter();
       
        try {
            final int theStart = (reversed) ? this.start+this.count-1 : this.start+this.count-lineCount;
            LogRecord record=null;
            for (int i = 0; i < lineCount; i++) {
                final int ix = (reversed) ?
                    Math.abs((theStart-i)%this.buffer.length) :
                    (theStart + i) % this.buffer.length;
                record = this.buffer[ix];
                logMessages.add(logFormatter.format(record));
            }
            return logMessages.toArray(new String[logMessages.size()]);
        } catch (final Exception ex) {
            // We don't want to throw an exception here, but we
            // report the exception to any registered ErrorManager.
View Full Code Here

      return;

    try {
      String value;

      Formatter formatter = getFormatter();
      if (formatter != null)
        value = formatter.format(record);
      else
        value = record.getMessage();

      _conn.message(_to, value);
    } catch (RuntimeException e) {
View Full Code Here

      return;

    try {
      String value;

      Formatter formatter = getFormatter();
      if (formatter != null)
        value = formatter.format(record);
      else
        value = record.getMessage();

      for (BlockingQueue queue : _queueList) {
        queue.offer(value);
View Full Code Here

      return;

    try {
      String value;

      Formatter formatter = getFormatter();
      if (formatter != null)
        value = formatter.format(record);
      else {
        value = record.getMessage();

        Throwable thrown = record.getThrown();
        if (thrown != null) {
View Full Code Here

      // Create an appending file handler
      new File(this.getDataFolder() + "/temp/").mkdir();
      FileHandler handler = new FileHandler(this.getDataFolder() + "/temp/war.log", true);

      // Add to War-specific logger
      Formatter formatter = new WarLogFormatter();
      handler.setFormatter(formatter);
      this.getLogger().addHandler(handler);
    } catch (IOException e) {
      this.getLogger().log(Level.WARNING, "Failed to create War log file");
    }
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.