org.objectweb.util.monolog.wrapper.javaLog
Class MonologFormatter

java.lang.Object
  extended byjava.util.logging.Formatter
      extended byorg.objectweb.util.monolog.wrapper.javaLog.MonologFormatter

public class MonologFormatter
extends java.util.logging.Formatter

The goal of this class is to format a LogRecord with regard to a pattern. In order to support support additional logging layer on top monolog, this class permits to specify package name or class names of its own logging layer. By default the org.apache.commons.logging package is included. To specify the list of names you have to assign the system property 'monolog.wrappers' with a list (separated with commas or white spaces) of your names.

Author:
S.Chassande-Barrioz

Field Summary
static java.lang.String WRAPPERS_PROPERTY
           
 
Constructor Summary
MonologFormatter()
           
MonologFormatter(java.lang.String strPattern)
           
 
Method Summary
 void format(java.util.Date date, java.lang.StringBuffer sbuf)
          Appends to sbuf the time in the format "YYYY-MM-DD HH:mm:ss,SSS" for example, "2004-04-28 15:49:37,459"
 java.lang.String format(java.util.logging.LogRecord record)
          Format the given log record and return the formatted string.
 java.lang.String format(java.lang.String msg, java.lang.String levelName, java.lang.String topic, long time)
           
static java.lang.String[] getContext()
          Calculate the class name, the method name and the line number of the logger user.
 java.lang.String getPattern()
           
 void setPattern(java.lang.String p)
           
 
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

WRAPPERS_PROPERTY

public static final java.lang.String WRAPPERS_PROPERTY
See Also:
Constant Field Values
Constructor Detail

MonologFormatter

public MonologFormatter()

MonologFormatter

public MonologFormatter(java.lang.String strPattern)
Method Detail

getPattern

public java.lang.String getPattern()

setPattern

public void setPattern(java.lang.String p)

format

public java.lang.String format(java.util.logging.LogRecord record)
Format the given log record and return the formatted string.

The resulting formatted String will normally include a localized and formated version of the LogRecord's message field. The Formatter.formatMessage convenience method can (optionally) be used to localize and format the message field.

Parameters:
record - the log record to be formatted.
Returns:
the formatted log record

getContext

public static java.lang.String[] getContext()
Calculate the class name, the method name and the line number of the logger user.

Returns:
a string array containing 3 String [ "classname", "method name", "line number"] ex: ["com.foo.Bar", "myMethod", "512"]

format

public void format(java.util.Date date,
                   java.lang.StringBuffer sbuf)
Appends to sbuf the time in the format "YYYY-MM-DD HH:mm:ss,SSS" for example, "2004-04-28 15:49:37,459"

Parameters:
date - the date to format
sbuf - the string buffer to write to

format

public java.lang.String format(java.lang.String msg,
                               java.lang.String levelName,
                               java.lang.String topic,
                               long time)