Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.logging

Class Formatter

java.lang.Object
|
+--java.util.logging.Formatter


public abstract class Formatter

extends Object

A Formatter supports handlers by localizing message texts and by subsituting parameter values for their placeholders.

Author:

Constructor Summary

Formatter()

Constructs a new Formatter.

Method Summary

java.lang.Stringformat(java.util.logging.LogRecord record)

Formats a LogRecord into a string.
java.lang.StringformatMessage(java.util.logging.LogRecord record)

Formats the message part of a log record.
java.lang.StringgetHead(java.util.logging.Handler handler)

Returns a string that handlers are supposed to emit before the first log record.
java.lang.StringgetTail(java.util.logging.Handler handler)

Returns a string that handlers are supposed to emit after the last log record.

Constructor Details

Formatter

protected Formatter()

Constructs a new Formatter.


Method Details

format

public String format(java.util.logging.LogRecord record)

Formats a LogRecord into a string. Usually called by handlers which need a string for a log record, for example to append a record to a log file or to transmit a record over the network.

Parameters:


formatMessage

public String formatMessage(java.util.logging.LogRecord record)

Formats the message part of a log record.

First, the Formatter localizes the record message to the default locale by looking up the message in the record's localization resource bundle. If this step fails because there is no resource bundle associated with the record, or because the record message is not a key in the bundle, the raw message is used instead.

Second, the Formatter substitutes appropriate strings for the message parameters. If the record returns a non-empty array for getParameters() and the localized message string contains the character sequence "{0", the formatter uses java.text.MessageFormat to format the message. Otherwise, no parameter substitution is performed.

Parameters:

Returns:

Throws:


getHead

public String getHead(java.util.logging.Handler handler)

Returns a string that handlers are supposed to emit before the first log record. The base implementation returns an empty string, but subclasses such as XMLFormatter override this method in order to provide a suitable header.

Parameters:

Returns:


getTail

public String getTail(java.util.logging.Handler handler)

Returns a string that handlers are supposed to emit after the last log record. The base implementation returns an empty string, but subclasses such as XMLFormatter override this method in order to provide a suitable tail.

Parameters:

Returns: