All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Logger.JFormatter Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * 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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy