Package wt.log4j.jmx

Class TSVLayout

java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout<String>
org.apache.logging.log4j.core.layout.AbstractStringLayout
wt.log4j.jmx.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

@Plugin(name="TSVLayout", category="Core", elementType="layout", printObject=true) public class TSVLayout extends org.apache.logging.log4j.core.layout.AbstractStringLayout
Tab-separated-values layout that is 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 Type
    Method
    Description
    void
    Necessary to activate some of this layout's settings.
    final String
    format(org.apache.logging.log4j.core.LogEvent loggingEvent)
    Format a LogEvent as a tab-separated-values output line.
    protected AttributeList
    Derives AttributeList from log message object

    Supported API: true
    Return appropriate MIME type for output, text/tab-separated-values

    Supported API: true
    final String
    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
    final String
    Get accessor for attributes to obtain when message turns out to be a DynamicMBean.
    final String
    Get accessor for file which column header names are read from and written to.
    final String
    Get accessor for header file encoding.
    final String
    Get initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.
    final String
    Get accessor for comma-delimited list of item names to perform a collection-like expansion on.
    final String
    Get accessor for items (field names) to exclude from output

    Supported API: true
    final String
    Get accessor for specific log4j MDC (mapped diagnostic context) items to include in output.
    final String
    Get customer renderer map as string.
    final boolean
    Deprecated.
    With log4j2 this api will not have any relevance.
    final boolean
    Get accessor for whether columns beyond those read from the header file or provided by the initialHeaders property are allowed

    Supported API: true
    final boolean
    Get accessor for whether log4j MDC (mapped diagnostic context) data should be included in output

    Supported API: true
    final boolean
    Get accessor for whether log4j NDC (nested diagnostic context) data should be included in output

    Supported API: true
    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
    final void
    setDateFormat(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: true
    final void
    setDynamicMBeanAttrsToInclude(String dynamicMBeanAttrsToInclude)
    Set accessor for attributes to obtain when message turns out to be a DynamicMBean.
    final void
    setHeaderFile(String headerFile)
    Set accessor for file which column header names are read from and written to.
    final void
    setHeaderFileEncoding(String headerFileEncoding)
    Set accessor for header file encoding.
    final void
    setIncludeMDC(boolean includeMDC)
    Set accessor for whether log4j MDC (mapped diagnostic context) data should be included in output

    Supported API: true
    final void
    setIncludeNDC(boolean includeNDC)
    Set accessor for whether log4j NDC (nested diagnostic context) data should be included in output

    Supported API: true
    final void
    setInitialHeaders(String initialHeaders)
    Set initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.
    final void
    setItemsToCollectionExpand(String itemsToCollectionExpand)
    Set accessor for comma-delimited list of item names to perform a collection-like expansion on.
    final void
    setItemsToExclude(String itemsToExclude)
    Set accessor for items (field names) to exclude from output

    Supported API: true
    final void
    setMDCItemsToInclude(String mdcItemsToInclude)
    Set accessor for specific log4j MDC (mapped diagnostic context) items to include in output.
    final void
    setRendererMap(String rendererMap)
    Set customer renderer map from string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getHeaderFile

      public final String getHeaderFile()
      Get accessor for file which column header names are read from and written to.

      Supported API: true
    • setHeaderFile

      public final void setHeaderFile(String headerFile)
      Set accessor for file which column header names are read from and written to.

      Supported API: true
    • getHeaderFileEncoding

      public final String getHeaderFileEncoding()
      Get accessor for header file encoding.

      Supported API: true
    • setHeaderFileEncoding

      public final void setHeaderFileEncoding(String headerFileEncoding)
      Set accessor for header file encoding.

      Supported API: true
    • getDateFormat

      public final String 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

      public final void setDateFormat(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: 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

      public final String getMDCItemsToInclude()
      Get accessor for specific log4j MDC (mapped diagnostic context) items to include in output. See Log4jConstants. Ignored when IncludeMDC property is false. If null, all MDC items will be included.

      Supported API: true
    • setMDCItemsToInclude

      public final void setMDCItemsToInclude(String mdcItemsToInclude)
      Set accessor for specific log4j MDC (mapped diagnostic context) items to include in output. See Log4jConstants. Ignored when IncludeMDC property is false. If null, all MDC items will be included.

      Supported API: true
    • getDynamicMBeanAttrsToInclude

      public final String getDynamicMBeanAttrsToInclude()
      Get accessor for attributes to obtain when message turns out to be a DynamicMBean. Obtains all readable attribute when null, which is generally not a good idea performance-wise.

      Supported API: true
    • setDynamicMBeanAttrsToInclude

      public final void setDynamicMBeanAttrsToInclude(String dynamicMBeanAttrsToInclude)
      Set accessor for attributes to obtain when message turns out to be a DynamicMBean. Obtains all readable attribute when null, which is generally not a good idea performance-wise.

      Supported API: true
    • getItemsToExclude

      public final String getItemsToExclude()
      Get accessor for items (field names) to exclude from output

      Supported API: true
    • setItemsToExclude

      public final void setItemsToExclude(String itemsToExclude)
      Set accessor for items (field names) to exclude from output

      Supported API: true
    • getItemsToCollectionExpand

      public final String 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

      public final void setItemsToCollectionExpand(String itemsToCollectionExpand)
      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

      public final String getRendererMap()
      Get customer renderer map as string. See CustomRendererSupport for more information.

      Supported API: true
    • setRendererMap

      public final void setRendererMap(String rendererMap)
      Set customer renderer map from string. See CustomRendererSupport for more information.

      Supported API: true
    • getInitialHeaders

      public final String getInitialHeaders()
      Get initial headers used (as a tab delimited list) if HeaderFile is not specified or does not yet exist.

      Supported API: true
    • setInitialHeaders

      public final void setInitialHeaders(String initialHeaders)
      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

      public String getContentType()
      Return appropriate MIME type for output, text/tab-separated-values

      Supported API: true
      Specified by:
      getContentType in interface org.apache.logging.log4j.core.Layout<String>
      Overrides:
      getContentType in class org.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 incoming LoggingEvent, but we do not want anything else doing so for us either.

      Supported API: true
    • format

      public final String format(org.apache.logging.log4j.core.LogEvent loggingEvent)
      Format a LogEvent as a tab-separated-values output line.

      Supported API: true
    • getAttributeList

      protected AttributeList getAttributeList(Object message)
      Derives AttributeList from log message object

      Supported API: true