Formatter


Formatter java.util.logging

Java 1.4

A Formatter object is used by a Handler to convert a LogRecord to a String prior to logging it. Most applications can simply use one one of the pre-defined concrete subclasses: SimpleFormatter or XMLFormatter . Applications requiring custom formatting of log messages will need to subclass this class and define the format( ) method to perform the desired conversion. Such subclasses may find the formatMessage( ) method useful: it performs localization using java.util.ResourceBundle and formatting using the facilities of the java.text package. getHead( ) and getTail( ) return a prefix and suffix (such as opening and closing XML tags) for a log file.

 public abstract class  Formatter  {  // Protected Constructors  protected  Formatter  ( );  // Public Instance Methods  public abstract String  format  (LogRecord  record  );        public String  formatMessage  (LogRecord  record  );  synchronized  public String  getHead  (Handler  h  );        public String  getTail  (Handler  h  );   } 

Subclasses

SimpleFormatter , XMLFormatter

Passed To

Handler.setFormatter( ) , StreamHandler.StreamHandler( )

Returned By

Handler.getFormatter( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net