org.apache.log4j.helpers

Class DateLayout

Implemented Interfaces:
OptionHandler
Known Direct 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

static String
DATE_FORMAT_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm.
static String
NULL_DATE_FORMAT
String constant designating no time information.
static String
RELATIVE_TIME_DATE_FORMAT
String constant designating relative time.
static String
TIMEZONE_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm.
protected Date
date
protected DateFormat
dateFormat
protected FieldPosition
pos

Fields inherited from class org.apache.log4j.Layout

LINE_SEP, LINE_SEP_LEN

Method Summary

void
activateOptions()
void
dateFormat(StringBuffer buf, LoggingEvent event)
String
getDateFormat()
Returns value of the DateFormat option.
String[]
getOptionStrings()
Deprecated. Use the setter method for the option directly instead of the generic setOption method.
String
getTimeZone()
Returns value of the TimeZone option.
void
setDateFormat(DateFormat dateFormat, TimeZone timeZone)
Sets the DateFormat used to format time and date in the zone determined by timeZone.
void
setDateFormat(String dateFormat)
The value of the DateFormat option should be either an argument to the constructor of SimpleDateFormat or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.
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)
Deprecated. Use the setter method for the option directly instead of the generic setOption method.
void
setTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by the TimeZone.getTimeZone method.

Methods inherited from class org.apache.log4j.Layout

format, getContentType, getFooter, getHeader, ignoresThrowable

Field Details

DATE_FORMAT_OPTION

public static final String DATE_FORMAT_OPTION

Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.


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.

TIMEZONE_OPTION

public static final String TIMEZONE_OPTION

Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.


date

protected Date date

dateFormat

protected DateFormat dateFormat

pos

protected FieldPosition pos

Method Details

activateOptions

public void activateOptions()
Specified by:
activateOptions in interface OptionHandler

dateFormat

public void dateFormat(StringBuffer buf,
                       LoggingEvent event)

getDateFormat

public String getDateFormat()
Returns value of the DateFormat option.

getOptionStrings

public String[] getOptionStrings()

Deprecated. Use the setter method for the option directly instead of the generic setOption method.


getTimeZone

public String getTimeZone()
Returns value of the TimeZone option.

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 dateFormat)
The value of the DateFormat option should be either an argument to the constructor of SimpleDateFormat or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.

setDateFormat

public void setDateFormat(String dateFormatType,
                          TimeZone timeZone)

setOption

public void setOption(String option,
                      String value)

Deprecated. Use the setter method for the option directly instead of the generic setOption method.


setTimeZone

public void setTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by the TimeZone.getTimeZone method.

Copyright 2000-2005 Apache Software Foundation.