Log4j 0.9.1

org.log4j.helpers
Class DateLayout

java.lang.Object
  |
  +--org.log4j.Layout
        |
        +--org.log4j.helpers.DateLayout
All Implemented Interfaces:
OptionHandler
Direct Known Subclasses:
TTCCLayout

public abstract class DateLayout
extends Layout

This abstract layout takes care of all the date related options and formatting work.

Author:
Ceki Gülcü

Field Summary
protected  Date date
           
static String DATE_FORMAT_OPTION
           
protected  DateFormat dateFormat
           
static String NULL_DATE_FORMAT
          String constant designating no time information.
protected  FieldPosition pos
           
static String RELATIVE_TIME_DATE_FORMAT
          String constant designating relative time.
static String TIMEZONE_OPTION
           
 
Fields inherited from class org.log4j.Layout
LINE_SEP, LINE_SEP_LEN
 
Constructor Summary
DateLayout()
           
 
Method Summary
 void activateOptions()
          Activate the options that were previously set with calls to setOption.
 void dateFormat(StringBuffer buf, LoggingEvent event)
           
 String[] getOptionStrings()
          Return list of strings that the OptionHandler instance recognizes.
 void setDateFormat(DateFormat dateFormat, TimeZone timeZone)
          Sets the DateFormat used to format time and date in the zone determined by timeZone.
 void setDateFormat(String dateFormatType)
           
 void setDateFormat(String dateFormatType, TimeZone timeZone)
          Sets the DateFormat used to format date and time in the time zone determined by timeZone parameter.
 void setOption(String option, String value)
          The DateLayout specific options are:
 
Methods inherited from class org.log4j.Layout
format, ignoresThrowable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_DATE_FORMAT

public static final String NULL_DATE_FORMAT
String constant designating no time information. Current value of this constant is NULL.

RELATIVE_TIME_DATE_FORMAT

public static final String RELATIVE_TIME_DATE_FORMAT
String constant designating relative time. Current value of this constant is RELATIVE.

pos

protected FieldPosition pos

DATE_FORMAT_OPTION

public static final String DATE_FORMAT_OPTION

TIMEZONE_OPTION

public static final String TIMEZONE_OPTION

dateFormat

protected DateFormat dateFormat

date

protected Date date
Constructor Detail

DateLayout

public DateLayout()
Method Detail

activateOptions

public void activateOptions()
Description copied from interface: OptionHandler
Activate the options that were previously set with calls to setOption.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.

For example, the FileAppender has the "File" and "Append" options both of which are ambigous until the other is also set.


getOptionStrings

public String[] getOptionStrings()
Description copied from interface: OptionHandler
Return list of strings that the OptionHandler instance recognizes.

dateFormat

public void dateFormat(StringBuffer buf,
                       LoggingEvent event)

setDateFormat

public void setDateFormat(DateFormat dateFormat,
                          TimeZone timeZone)
Sets the DateFormat used to format time and date in the zone determined by timeZone.

setDateFormat

public void setDateFormat(String dateFormatType)

setDateFormat

public void setDateFormat(String dateFormatType,
                          TimeZone timeZone)
Sets the DateFormat used to format date and time in the time zone determined by timeZone parameter. The DateFormat used will depend on the dateFormatType.

The recognized types are NULL_DATE_FORMAT, RELATIVE_TIME_DATE_FORMAT AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT, AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT and AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT. If the dateFormatType is not one of the above, then the argument is assumed to be a date pattern for SimpleDateFormat.


setOption

public void setOption(String option,
                      String value)

The DateLayout specific options are:

DateFormat
The value of this option should be either an argument to the constructor of SimpleDateFormat or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.

See also the %d conversion specifier of the PatternLayout.

TimeZoneID
A time zone ID string in the format expected by the TimeZone.getTimeZone(java.lang.String) method.

Log4j 0.9.1

Please notify me about new log4j releases.