Class TSVLayout
- All Implemented Interfaces:
org.apache.logging.log4j.core.impl.LocationAware,org.apache.logging.log4j.core.Layout<String>,org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>,org.apache.logging.log4j.core.StringLayout
AttributeListProvider (e.g. AttributeListWrapper),
AttributeList, DynamicMBean, and CompositeData aware.
Each data field to be output is associated with a name. Fields of the
incoming LoggingEvent are given names prefaced by "LE.", e.g.
LE.Timestamp. If the LoggingEvent's message is not an AttributeListProvider, AttributeList,
DynamicMBean, or CompositeData, then this message is treated as one field and associated
with the name "LE.Message". If, however, the message is an AttributeListProvider, AttributeList,
DynamicMBean, or CompositeData, then it is treated as one field per attribute therein,
each associated with its name. In the case of a DynamicMBean, the set of
attributes obtained can be controlled via setDynamicMBeanAttrsToInclude(),
else all of the MBean's readable attributes are obtained for output. Separate
fields are also generated for each item within a CompositeData field, recursively.
One can also optionally generate separate fields for each item with an array, collection,
or TabularData structure through the ItemsToCollectionExpand property.
Once this layout encounters a field name it remembers the column it is being output in and will reserve this column for this field from thereon. If a header file is specified, the field names will be output in tab-separated value format, each in its column whenever the layout encounters a new field name. This allows unambiguous interpretation of the tab-separated-values log output produced by the layout. The field column mapping is also initialized from this header file when it is initially specified, thus both preserving this mapping between executions and allowing this mapping to be tailored by editing the header file.
One can also exclude specific fields from output by name via
setItemsToExclude().
Supported API: true
Extendable: true
-
Method Summary
Modifier and TypeMethodDescriptionvoidNecessary to activate some of this layout's settings.final Stringformat(org.apache.logging.log4j.core.LogEvent loggingEvent) Format aLogEventas a tab-separated-values output line.protected AttributeListgetAttributeList(Object message) Return appropriate MIME type for output, text/tab-separated-values
Supported API: truefinal StringGet accessor for date format used; if this is null, then the millisecond count since the epoch is output for top-level fields and a default date format is used elsewhere
Supported API: truefinal StringGet accessor for attributes to obtain when message turns out to be aDynamicMBean.final StringGet accessor for file which column header names are read from and written to.final StringGet accessor for header file encoding.final StringGet initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.final StringGet accessor for comma-delimited list of item names to perform a collection-like expansion on.final StringGet accessor for items (field names) to exclude from output
Supported API: truefinal StringGet accessor for specific log4j MDC (mapped diagnostic context) items to include in output.final StringGet customer renderer map as string.final booleanDeprecated.With log4j2 this api will not have any relevance.final booleanGet accessor for whether columns beyond those read from the header file or provided by the initialHeaders property are allowed
Supported API: truefinal booleanGet accessor for whether log4j MDC (mapped diagnostic context) data should be included in output
Supported API: truefinal booleanGet accessor for whether log4j NDC (nested diagnostic context) data should be included in output
Supported API: truefinal voidsetAllowOnlyExistingColumns(boolean allowOnlyExistingColumns) Get accessor for whether columns beyond those read from the header file or provided by the initialHeaders property are allowed
Supported API: truefinal voidsetDateFormat(String dateFormatString) Set accessor for date format used; if this is null, then the millisecond count since the epoch is output for top-level fields and a default date format is used elsewhere
Supported API: truefinal voidsetDynamicMBeanAttrsToInclude(String dynamicMBeanAttrsToInclude) Set accessor for attributes to obtain when message turns out to be aDynamicMBean.final voidsetHeaderFile(String headerFile) Set accessor for file which column header names are read from and written to.final voidsetHeaderFileEncoding(String headerFileEncoding) Set accessor for header file encoding.final voidsetIncludeMDC(boolean includeMDC) Set accessor for whether log4j MDC (mapped diagnostic context) data should be included in output
Supported API: truefinal voidsetIncludeNDC(boolean includeNDC) Set accessor for whether log4j NDC (nested diagnostic context) data should be included in output
Supported API: truefinal voidsetInitialHeaders(String initialHeaders) Set initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.final voidsetItemsToCollectionExpand(String itemsToCollectionExpand) Set accessor for comma-delimited list of item names to perform a collection-like expansion on.final voidsetItemsToExclude(String itemsToExclude) Set accessor for items (field names) to exclude from output
Supported API: truefinal voidsetMDCItemsToInclude(String mdcItemsToInclude) Set accessor for specific log4j MDC (mapped diagnostic context) items to include in output.final voidsetRendererMap(String rendererMap) Set customer renderer map from string.
-
Method Details
-
getHeaderFile
Get accessor for file which column header names are read from and written to.
Supported API: true -
setHeaderFile
Set accessor for file which column header names are read from and written to.
Supported API: true -
getHeaderFileEncoding
Get accessor for header file encoding.
Supported API: true -
setHeaderFileEncoding
Set accessor for header file encoding.
Supported API: true -
getDateFormat
Get accessor for date format used; if this is null, then the millisecond count since the epoch is output for top-level fields and a default date format is used elsewhere
Supported API: true -
setDateFormat
Set accessor for date format used; if this is null, then the millisecond count since the epoch is output for top-level fields and a default date format is used elsewhere
Supported API: true -
isAllowOnlyExistingColumns
public final boolean isAllowOnlyExistingColumns()Get accessor for whether columns beyond those read from the header file or provided by the initialHeaders property are allowed
Supported API: true -
setAllowOnlyExistingColumns
public final void setAllowOnlyExistingColumns(boolean allowOnlyExistingColumns) Get accessor for whether columns beyond those read from the header file or provided by the initialHeaders property are allowed
Supported API: true -
isIncludeNDC
public final boolean isIncludeNDC()Get accessor for whether log4j NDC (nested diagnostic context) data should be included in output
Supported API: true -
setIncludeNDC
public final void setIncludeNDC(boolean includeNDC) Set accessor for whether log4j NDC (nested diagnostic context) data should be included in output
Supported API: true -
isIncludeMDC
public final boolean isIncludeMDC()Get accessor for whether log4j MDC (mapped diagnostic context) data should be included in output
Supported API: true -
setIncludeMDC
public final void setIncludeMDC(boolean includeMDC) Set accessor for whether log4j MDC (mapped diagnostic context) data should be included in output
Supported API: true -
getMDCItemsToInclude
Get accessor for specific log4j MDC (mapped diagnostic context) items to include in output. SeeLog4jConstants. Ignored when IncludeMDC property is false. If null, all MDC items will be included.
Supported API: true -
setMDCItemsToInclude
Set accessor for specific log4j MDC (mapped diagnostic context) items to include in output. SeeLog4jConstants. Ignored when IncludeMDC property is false. If null, all MDC items will be included.
Supported API: true -
getDynamicMBeanAttrsToInclude
Get accessor for attributes to obtain when message turns out to be aDynamicMBean. Obtains all readable attribute when null, which is generally not a good idea performance-wise.
Supported API: true -
setDynamicMBeanAttrsToInclude
Set accessor for attributes to obtain when message turns out to be aDynamicMBean. Obtains all readable attribute when null, which is generally not a good idea performance-wise.
Supported API: true -
getItemsToExclude
Get accessor for items (field names) to exclude from output
Supported API: true -
setItemsToExclude
Set accessor for items (field names) to exclude from output
Supported API: true -
getItemsToCollectionExpand
Get accessor for comma-delimited list of item names to perform a collection-like expansion on. Items to be expanded must be of either array, collection, or TabularData types. The expansion adds attributes of the form {AttributeItemNamePrefix}{AttributeName}.{index}, where index starts at 1. If the list contains "*", then all collection-like items are expanded.
Supported API: true -
setItemsToCollectionExpand
Set accessor for comma-delimited list of item names to perform a collection-like expansion on. Items to be expanded must be of either array, collection, or TabularData types. The expansion adds attributes of the form {AttributeItemNamePrefix}{AttributeName}.{index}, where index starts at 1. If the list contains "*", then all collection-like items are expanded.
Supported API: true -
getRendererMap
Get customer renderer map as string. SeeCustomRendererSupportfor more information.
Supported API: true -
setRendererMap
Set customer renderer map from string. SeeCustomRendererSupportfor more information.
Supported API: true -
getInitialHeaders
Get initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.
Supported API: true -
setInitialHeaders
Set initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.
Supported API: true -
activateOptions
public void activateOptions()Necessary to activate some of this layout's settings.
Supported API: true -
getContentType
Return appropriate MIME type for output, text/tab-separated-values
Supported API: true- Specified by:
getContentTypein interfaceorg.apache.logging.log4j.core.Layout<String>- Overrides:
getContentTypein classorg.apache.logging.log4j.core.layout.AbstractStringLayout
-
ignoresThrowable
public final boolean ignoresThrowable()Deprecated.With log4j2 this api will not have any relevance.Returns 'false' as this class does not output the throwable from the incomingLoggingEvent, but we do not want anything else doing so for us either.
Supported API: true -
format
Format aLogEventas a tab-separated-values output line.
Supported API: true -
getAttributeList
-