SimpleLagacyLogFormatter.java :  » Maven » smart-codegen » com » smartitengineering » javasourcetreeparser » Java Open Source

Java Open Source » Maven » smart codegen 
smart codegen » com » smartitengineering » javasourcetreeparser » SimpleLagacyLogFormatter.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.smartitengineering.javasourcetreeparser;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

/**
 *
 * @author imyousuf
 */
public class SimpleLagacyLogFormatter extends Formatter {

  @Override
  public String format(LogRecord record) {
    StringBuilder formattedMessage = new StringBuilder();
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(record.getMillis());
    SimpleDateFormat dateFormat 
            = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    formattedMessage.append(dateFormat.format(calendar.getTime()));
    formattedMessage.append(' ');
    formattedMessage.append("[");
    formattedMessage.append(record.getLoggerName());
    formattedMessage.append("] ");
    formattedMessage.append(record.getLevel().getName());
    formattedMessage.append(": ");
    formattedMessage.append(record.getMessage());
    formattedMessage.append('\n');
    return formattedMessage.toString();
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.