FileDocCategorySizeDatePackage
SimpleFormatter.javaAPI DocJava SE 5 API2235Fri Aug 26 14:57:28 BST 2005java.util.logging

SimpleFormatter

public class SimpleFormatter extends Formatter
Print a brief summary of the LogRecord in a human readable format. The summary will typically be 1 or 2 lines.
version
1.14, 12/19/03
since
1.4

Fields Summary
Date
dat
private static final String
format
private MessageFormat
formatter
private Object[]
args
private String
lineSeparator
Constructors Summary
Methods Summary
public synchronized java.lang.Stringformat(java.util.logging.LogRecord record)
Format the given LogRecord.

param
record the log record to be formatted.
return
a formatted log record


                          
         
	StringBuffer sb = new StringBuffer();
	// Minimize memory allocations here.
	dat.setTime(record.getMillis());
	args[0] = dat;
	StringBuffer text = new StringBuffer();
	if (formatter == null) {
	    formatter = new MessageFormat(format);
	}
	formatter.format(args, text, null);
	sb.append(text);
	sb.append(" ");
	if (record.getSourceClassName() != null) {	
	    sb.append(record.getSourceClassName());
	} else {
	    sb.append(record.getLoggerName());
	}
	if (record.getSourceMethodName() != null) {	
	    sb.append(" ");
	    sb.append(record.getSourceMethodName());
	}
	sb.append(lineSeparator);
	String message = formatMessage(record);
	sb.append(record.getLevel().getLocalizedName());
	sb.append(": ");
	sb.append(message);
	sb.append(lineSeparator);
	if (record.getThrown() != null) {
	    try {
	        StringWriter sw = new StringWriter();
	        PrintWriter pw = new PrintWriter(sw);
	        record.getThrown().printStackTrace(pw);
	        pw.close();
		sb.append(sw.toString());
	    } catch (Exception ex) {
	    }
	}
	return sb.toString();