com.gridsystems.config.app
Class PatternFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by com.gridsystems.config.app.PatternFormatter

public class PatternFormatter
extends java.util.logging.Formatter

Logging formatter with log4j-like style.

Version:
1.0
Author:
Rodrigo Ruiz Aguayo

Field Summary
protected  java.lang.Object[] args
          The message format arguments.
protected  java.util.Date date
          The date to format.
protected  java.text.MessageFormat formatter
          The formatter to use.
protected  java.lang.String pattern
          The pattern.
protected  boolean showTrace
          if true, the stack trace is dumped.
 
Constructor Summary
PatternFormatter()
          Creates an instance with a default one line pattern.
PatternFormatter(java.lang.String pattern, boolean showTrace)
          Creates an instance that will use the specified pattern.
 
Method Summary
 java.lang.String format(java.util.logging.LogRecord record)
          
 
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

date

protected java.util.Date date
The date to format.


args

protected java.lang.Object[] args
The message format arguments.


formatter

protected java.text.MessageFormat formatter
The formatter to use.


pattern

protected java.lang.String pattern
The pattern.


showTrace

protected boolean showTrace
if true, the stack trace is dumped.

Constructor Detail

PatternFormatter

public PatternFormatter()
Creates an instance with a default one line pattern.

The default pattern is {0,date,dd/MM/yyyy HH:mm:ss} {1} - {2}


PatternFormatter

public PatternFormatter(java.lang.String pattern,
                        boolean showTrace)
Creates an instance that will use the specified pattern. The pattern will be used with three arguments:
  1. java.util.Date with the message date and time
  2. String with the message log level
  3. String with the message to log
If the message has an attached exception, its stacktrace will be presented only if the showTrace flag is set to true.

Parameters:
pattern - The pattern to use in this instance
showTrace - true if we want attached exceptions stack traces to be dumped
Method Detail

format

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

Specified by:
format in class java.util.logging.Formatter


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.