Alachisoft.NCache.Common.Logger.JFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Alachisoft.NCache.Common.Logger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
/**
* @author Muneeb Shahid
*/
public class JFormatter extends Formatter {
private static final DateFormat df = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss,SSS");
@Override
public String format(LogRecord record) {
StringBuilder builder = new StringBuilder(1000);
builder.append(df.format(new Date(record.getMillis()))).append(" ");
// builder.append("[").append(record.getSourceClassName()).append(".");
// builder.append(record.getSourceMethodName()).append("] - ");
builder.append(String.format("%-45s", record.getLoggerName()));
builder.append(String.format("%-35s", record.getThreadID()));
builder.append(String.format("%-20s", record.getLevel()));
builder.append(formatMessage(record));
builder.append("\r\n");
return builder.toString();
}
}