Package org.apache.log4j.helpers
Class DateLayout
java.lang.Object
org.apache.log4j.Layout
org.apache.log4j.helpers.DateLayout
- All Implemented Interfaces:
OptionHandler
- Direct Known Subclasses:
TTCCLayout
This abstract layout takes care of all the date related options and
formatting work.
- Author:
- Ceki Gülcü
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Date
static final String
Deprecated.Options are now handled using the JavaBeans paradigm.protected DateFormat
static final String
String constant designating no time information.protected FieldPosition
static final String
String constant designating relative time.static final String
Deprecated.Options are now handled using the JavaBeans paradigm.Fields inherited from class org.apache.log4j.Layout
LINE_SEP, LINE_SEP_LEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Activate the options that were previously set with calls to option setters.void
dateFormat
(StringBuffer buf, LoggingEvent event) Returns value of the DateFormat option.String[]
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.Returns value of the TimeZone option.void
setDateFormat
(String dateFormat) The value of the DateFormat option should be either an argument to the constructor ofSimpleDateFormat
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 bytimeZone
parameter.void
setDateFormat
(DateFormat dateFormat, TimeZone timeZone) Sets theDateFormat
used to format time and date in the zone determined bytimeZone
.void
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.void
setTimeZone
(String timeZone) The TimeZoneID option is a time zone ID string in the format expected by theTimeZone.getTimeZone(java.lang.String)
method.Methods inherited from class org.apache.log4j.Layout
format, getContentType, getFooter, getHeader, ignoresThrowable
-
Field Details
-
NULL_DATE_FORMAT
String constant designating no time information. Current value of this constant is NULL.- See Also:
-
RELATIVE_TIME_DATE_FORMAT
String constant designating relative time. Current value of this constant is RELATIVE.- See Also:
-
pos
-
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.- See Also:
-
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.- See Also:
-
dateFormat
-
date
-
-
Constructor Details
-
DateLayout
public DateLayout()
-
-
Method Details
-
getOptionStrings
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method. -
setOption
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method. -
setDateFormat
The value of the DateFormat option should be either an argument to the constructor ofSimpleDateFormat
or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601. -
getDateFormat
Returns value of the DateFormat option. -
setTimeZone
The TimeZoneID option is a time zone ID string in the format expected by theTimeZone.getTimeZone(java.lang.String)
method. -
getTimeZone
Returns value of the TimeZone option. -
activateOptions
public void activateOptions()Description copied from interface:OptionHandler
Activate the options that were previously set with calls to option setters.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
andAppend
options both of which are ambigous until the other is also set. -
dateFormat
-
setDateFormat
Sets theDateFormat
used to format time and date in the zone determined bytimeZone
. -
setDateFormat
Sets the DateFormat used to format date and time in the time zone determined bytimeZone
parameter. TheDateFormat
used will depend on thedateFormatType
.The recognized types are
NULL_DATE_FORMAT
,RELATIVE_TIME_DATE_FORMAT
AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT
,AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT
andAbsoluteTimeDateFormat.ISO8601_DATE_FORMAT
. If thedateFormatType
is not one of the above, then the argument is assumed to be a date pattern forSimpleDateFormat
.
-