About Pattern Layouts

Overview of Pattern Layouts

A pattern layout is a template that you create in order to format log messages for the appender classes in the SAS logging facility. The pattern layout that you define identifies the type of data, the order of the data, and the format of the data that is generated in a log event and that is delivered as output. A unique pattern layout is created for each instance of an appender class. You configure a pattern layout by using the <layout> appender subelement in a logging configuration file or the PATTERN attribute of an appender language element.
The pattern layout is created by using a conversion pattern, which consists of literal text and format-control directives. Format-control directives are also called conversion specifiers.
The conversion patterns that you use to format log messages are similar to, but not identical to, the conversion patterns that are used in the C language PRINTF statement.
Note: The conversion patterns that you use to format log messages are also similar to, but not identical to, these formatting methods that are used in these contexts:
  • the directives that are used in the SAS LOGPARM= system option to format log names.
  • the set of conversion patterns that are used by the ARMAppender. For details, see in SAS Interface to Application Response Measurement (ARM): Reference
The meaning of a specific character that is used in a pattern can vary according to the context. Do not interchange characters.
SAS issues an error message if the message layout fails.
Here is an example of a formatted log event that is delivered to the appropriate output device:
Example of Generated Logged Event
Date
Level
Thread ID
Logger
Filename or Line Number
Message
20008-06-25 10:24:22,234;
WARN;
3;
Appender.IOMCallContext;
(ynl4.sas.c:149);
Numeric maximum was larger than 8, am setting to 8.
Here is another view of the formatted log event as output:
2008–06–25–10:24:22,234; WARN; 3; Appender.IOMCallContext; (yn14.sas.c:149); 
Numeric maximum was larger than 8, am setting to 8.

Conversion Patterns Supplied by SAS

SAS supplies several conversion patterns that you can specify as the value for HeaderPattern, ConversionPattern, and FooterPattern parameters in appender configurations. You specify a conversion pattern name in place of the conversion pattern.
In this example, DEFAULTHEADER and DEFAULT are conversion pattern names:
<appender name="myDefault" class="FileAppender">
      <param name="File" value="default.log"/>
      <param name="ImmediateFlush" value="true"/>
      <param name="Append" value="false"/>
      <layout>
         <param name="HeaderPattern" value="DEFAULTHEADER"/>
         <param name="ConversionPattern" value="DEFAULT"/>
      </layout>
   </appender>
Here are some rules for using conversion pattern names:
  • Conversion pattern names are case sensitive and must be specified in uppercase letters.
  • Conversion pattern names cannot be specified with other conversion specifiers. For example, the following ConversionPattern value is not valid:
    <param name="ConversionPattern" value="%d:DEFAULT"/>
SAS supplies DEFAULT and DEFAULTHEADER conversion patterns for each version of SAS as well as a version-specific DEFAULTversion-number and DEFAULTHEADERversion-number conversion patterns. If the default layouts change in a new version of SAS, you can use the version-specific conversion patterns to use the previous version’s layout. If you have a program to parse logs, you might want to use the version-specific default. If the default conversion pattern changes in a new version of SAS, you do not need to change your program.
The following table lists the conversion patterns that SAS supplies.
Conversion Pattern Name and Description
Conversion Pattern1
DEFAULTHEADER
A default conversion pattern for the HeaderPattern value.
Host: '%S{hostname}', OS: '%S{os_family}', Release: '%S{os_release}', SAS Version: '%S{sup_ver_long2}', Command: '%S{startup_cmd}'
DEFAULT
A default conversion pattern for the ConversionPattern parameter.
%d %-5p [%t] %u - %m
DEFAULTHEADER9.3
A default conversion pattern for the HeaderPattern parameter in SAS 9.3.
Host: '%S{hostname}', OS: '%S{os_family}', Release: '%S{os_release}', SAS Version: '%S{sup_ver_long2}', Command: '%S{startup_cmd}'
DEFAULT9.3
A default conversion pattern for the ConversionPattern parameter in SAS 9.3.
%d %-5p [%t] %u - %m
TRACE
A conversion pattern to use for tracing messages.
%d %-5p [%t] (%F:%L) %c - %u - %m
TRACE9.3
A conversion pattern to use for tracing messages in SAS 9.3.
%d %-5p [%t] (%F:%L) %c - %u - %m
CBE101HEADER
A HeaderPattern parameter value for the Common Base Event V1.0.1.
<?xml version="1.0" encoding="UTF-8"?> 
   <CommonBaseEvents 
      xmlns="http://www.ibm.com/AC/commonbaseevent1_0_1" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
CBE101
A ConversionPattern parameter value for the Common Base Event V1.0.1.
<CommonBaseEvent creationTime="%d{ISO8601ZONEDOT}"%n
   version="1.0.1"%n
   severity="%0.1severity{CBE}"%n
   sequenceNumber="%0.1sn"%n
   msg="%m"%n
   xmlns="http://www.ibm.com/AC/commonbaseevent1_0_1"%n
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">%n
   <contextDataElements name="ServerType" type="uuid">%n
      <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerPort" type="number">%n
      <contextValue>%S{TKIOM.PORT}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerKnownBy" type="string">%n
      <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="UserId" type="string">%n
      <contextValue>%u</contextValue>%n
   </contextDataElements>%n
   <sourceComponentId%n
      component="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                    #%S{sup_ver_long2},%S{version}"%n
      subComponent="%c"%n
      componentIdType="ProductName"%n
      location="%S{hostname}"%n
      locationType="Hostname"%n
      processId="%S{pid}"%n
      threadId="%0.1t"%n
      application="%S{App.Name|SAS}"%n
      componentType="Logger"/>%n
   <situation categoryName="ReportSituation">%n
      <situationType xsi:type="ReportSituation"%n
         reasoningScope="INTERNAL"%n
         reportCategory="LOG"/>%n
   </situation>%n
</CommonBaseEvent>
CBE101FOOTER
A FooterPattern parameter value for the Common Base Event V1.0.1.
</CommonBaseEvents>
CBE101CORRELATORSHEADER
A Header Pattern parameter value to use with ARM correlators and Common Base Event V1.0.1.
<?xml version="1.0" encoding="UTF-8"?> 
   <CommonBaseEvents 
      xmlns="http://www.ibm.com/AC/commonbaseevent1_0_1" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
CBE101CORRELATORS
A ConversionPattern parameter value to use with ARM correlators and Common Base Event V1.0.1.
<CommonBaseEvent creationTime="%d{ISO8601ZONEDOT}"%n
   version="1.0.1"%n
   severity="%0.1severity{CBE}"%n
   sequenceNumber="%0.1sn"%n
   msg="%m"%n
   xmlns="http://www.ibm.com/AC/commonbaseevent1_0_1"%n
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">%n
   <contextDataElements name="ServerType" type="uuid">%n
      <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerPort" type="number">%n
      <contextValue>%S{TKIOM.PORT}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerKnownBy" type="string">%n
      <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="UserId" type="string">%n
      <contextValue>%u</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ParentCorrelator" type="string">%n
      <contextValue>%X{ARM.ParentCorrelator}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="CurrentCorrelator" type="string">%n
      <contextValue>%X{ARM.CurrentCorrelator}</contextValue>%n
   </contextDataElements>%n
   <sourceComponentId%n
      component="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                    #%S{sup_ver_long2},%S{version}"%n
      subComponent="%c"%n
      componentIdType="ProductName"%n
      location="%S{hostname}"%n
      locationType="Hostname"%n
      processId="%S{pid}"%n
      threadId="%0.1t"%n
      application="%S{App.Name|SAS}"%n
      componentType="Logger"/>%n
   <situation categoryName="ReportSituation">%n
      <situationType xsi:type="ReportSituation"%n
         reasoningScope="INTERNAL"%n
         reportCategory="LOG"/>%n
   </situation>%n
</CommonBaseEvent>
CBE101CORRELATORSFOOTER
A FooterPattern parameter value to use with ARM correlators and Common Base Event 1.0.1.
</CommonBaseEvents>
CBE111HEADER
A HeaterPattern parameter value to use with Common Base Event V1.1.1.
<?xml version="1.0" encoding="UTF-8"?> 
   <cbe:CommonBaseEvents 
      xmlns:cbe="http://www.ibm.com/AC/commonbaseevent1_1">
CBE111
A ConversionPattern parameter value to use with Common Base Event V1.1.1.
<cbe:CommonBaseEvent>%n
   <sourceComponentId%n
      component="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                    #%S{sup_ver_long2},%S{version}"%n
      subComponent="%c"%n
      componentIdType="Logger"%n
      location="%S{hostname}"%n
      locationType="Hostname"%n
      processId="%S{pid}"%n
      threadId="%0.1t"%n
      application="%S{App.Name|SAS}"/>%n
   <situationInformation%n
      creationTime="%d{ISO8601ZONEDOT}"%n
      severity="%0.1severity{CBE}"%n
      sequenceNumber="%0.1sn"%n
      msg="%m">%n
      <contextDataElements name="ServerType" type="clsid">%n
         <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="ServerPort" type="number">%n
         <contextValue>%S{TKIOM.PORT}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="ServerKnownBy" type="string">%n
         <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="UserId" type="string">%n
         <contextValue>%u</contextValue>%n
      </contextDataElements>%n
      <situationType category="REPORT"%n
         successDisposition="SUCCESSFUL"%n
         situationQualifier="LOG"%n
         reasoningScope="INTERNAL"/>%n
   </situationInformation>%n
</cbe:CommonBaseEvent>
CBE111FOOTER
A FooterPattern parameter value to use with Common Base Event V1.1.1.
</cbe:CommonBaseEvents>
CBE111CORRELATORSHEADER
A HeaderPattern parameter value to use for ARM correlators and Common Base Event V1.1.1.
<?xml version="1.0" encoding="UTF-8"?> 
   <cbe:CommonBaseEvents x
      mlns:cbe="http://www.ibm.com/AC/commonbaseevent1_1">
CBE111CORRELATORS
A ConversionPattern parameter value to use for ARM correlators and Common Base Event V1.1.1.
<cbe:CommonBaseEvent>%n
   <sourceComponentId%n
     component="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                    #%S{sup_ver_long2},%S{version}"%n
     subComponent="%c"%n
     componentIdType="Logger"%n
     location="%S{hostname}"%n
     locationType="Hostname"%n
     processId="%S{pid}"%n
     threadId="%0.1t"%n
     application="%S{App.Name|SAS}"/>%n
   <situationInformation%n
      creationTime="%d{ISO8601ZONEDOT}"%n
      severity="%0.1severity{CBE}"%n
      sequenceNumber="%0.1sn"%n
      msg="%m">%n
      <contextDataElements name="ServerType" type="clsid">%n
         <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="ServerPort" type="number">%n
         <contextValue>%S{TKIOM.PORT}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="ServerKnownBy" type="string">%n
         <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="UserId" type="string">%n
         <contextValue>%u</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="ParentCorrelator" type="string">%n
         <contextValue>%X{ARM.ParentCorrelator}</contextValue>%n
      </contextDataElements>%n
      <contextDataElements name="CurrentCorrelator" type="string">%n
         <contextValue>%X{ARM.CurrentCorrelator}</contextValue>%n
      </contextDataElements>%n
      <situationType category="REPORT"%n
         successDisposition="SUCCESSFUL"%n
         situationQualifier="LOG"%n
         reasoningScope="INTERNAL"/>%n
   </situationInformation>%n
</cbe:CommonBaseEvent>
CBE111CORRELATORSFOOTER
A FooterPattern parameter value to use for ARM correlators and Common Base Event V1.1.1.
</cbe:CommonBaseEvents>
WEFHEADER
A HeaderPattern parameter value to use for Web Services Distributed Management (WSDM) Event Format (WEF).
<?xml version="1.0" encoding="UTF-8"?> <ManagementEvents>
WEF
A ConversionPattern parameter value to use for WSDM Event Format.
<muws1:ManagementEvent ReportTime="%d{ISO8601ZONEDOT}"%n
   xmlns:muws1="http://docs.oasis-open.org/wsdm/muws1-2.xsd"%n
   xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd">%n
   <muws1:EventId>uuid:%uuid</muws1:EventId>%n
   <muws1:SourceComponent>%n
      <Host>%S{hostname}</Host>%n
      <Pid>%S{pid}</Pid>%n
      <Logger name="%c" level="%p"/>%n
      <Component name="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                          #%S{sup_ver_long2},%S{version}"/>%n
   </muws1:SourceComponent>%n
   <muws2:EventCorrelationProperties sequenceNumber="%0.1sn"/>%n
   <muws2:Situation>%n
      <muws2:SituationTime>%d{ISO8601ZONEDOT}</muws2:SituationTime>%n
      <muws2:SituationCategory>%n
         <muws2:LogReport><muws2:ReportSituation/></muws2:LogReport>%n
      </muws2:SituationCategory>%n
      <muws2:Severity>%0.1severity{WEF}</muws2:Severity>%n
      <muws2:Message>%m</muws2:Message>%n
   </muws2:Situation>%n
   <contextDataElements name="ServerType" type="clsid">%n
      <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerPort" type="number">%n
      <contextValue>%S{TKIOM.PORT}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerKnownBy" type="string">%n
      <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="UserId" type="string">%n
      <contextValue>%u</contextValue>%n
   </contextDataElements>%n
</muws1:ManagementEvent>
WEFFOOTER
A FooterPattern parameter value to use for WSDM Event Format.
</ManagementEvents>
WEFCORRELATORSHEADER
A HeaderPattern parameter value to use for ARM correlators and WSDM Event Format.
<?xml version="1.0" encoding="UTF-8"?> <ManagementEvents>
 
WEFCORRELATORS
A ConversionPattern parameter value to use for ARM correlators and WSDM Event Format.
<muws1:ManagementEvent ReportTime="%d{ISO8601ZONEDOT}"%n
   xmlns:muws1="http://docs.oasis-open.org/wsdm/muws1-2.xsd"%n
   xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd">%n
   <muws1:EventId>uuid:%uuid</muws1:EventId>%n
   <muws1:SourceComponent>%n
      <Host>%S{hostname}</Host>%n
      <Pid>%S{pid}</Pid>%n
      <Logger name="%c" level="%p"/>%n
      <Component name="%S{TKIOM.SERVER_COMPONENT_NAME|SAS}
                          #%S{sup_ver_long2},%S{version}"/>%n
   </muws1:SourceComponent>%n
   <muws2:EventCorrelationProperties sequenceNumber="%0.1sn"/>%n
   <muws2:Situation>%n
      <muws2:SituationTime>%d{ISO8601ZONEDOT}</muws2:SituationTime>%n
      <muws2:SituationCategory>%n
        <muws2:LogReport><muws2:ReportSituation/></muws2:LogReport>%n
      </muws2:SituationCategory>%n
      <muws2:Severity>%0.1severity{WEF}</muws2:Severity>%n
      <muws2:Message>%m</muws2:Message>%n
   </muws2:Situation>%n
   <contextDataElements name="ServerType" type="clsid">%n
      <contextValue>%S{TKIOM.BASE_CLSID}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerPort" type="number">%n
     <contextValue>%S{TKIOM.PORT}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ServerKnownBy" type="string">%n
      <contextValue>%S{TKIOM.KNOWN_BY}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="UserId" type="string">%n
      <contextValue>%u</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="ParentCorrelator" type="string">%n
      <contextValue>%X{ARM.ParentCorrelator}</contextValue>%n
   </contextDataElements>%n
   <contextDataElements name="CurrentCorrelator" type="string">%n
      <contextValue>%X{ARM.CurrentCorrelator}</contextValue>%n
   </contextDataElements>%n
</muws1:ManagementEvent>
WEFCORRELATORSFOOTER
A FooterPattern parameter value to use for ARM correlators and WSDM Event Format.
</ManagementEvents>
1Operating Environment Information for z/OS: When you specify %uuid or WEF in a logging facility configuration file, the identifiers that SAS creates are unique only for the current computer node. %uuid or WEF does not create a UUID. You can obtain a computer node name by using the %S{ hostname}conversion character.