Implement Athena logback output pattern 18/3018/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Wed, 3 Oct 2018 13:13:02 +0000 (09:13 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Wed, 3 Oct 2018 13:59:13 +0000 (09:59 -0400)
Use federation.instance=gateway in sample properties files so app starts.

Change-Id: Icd8ba153be84af677a590445579e2bce342a8676
Issue-ID: ACUMOS-710
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
docs/developer-guide.rst
gateway/application-acumosa.properties
gateway/application-acumosb.properties
gateway/pom.xml
gateway/src/main/resources/logback.xml

index 0122859..40e559e 100644 (file)
@@ -48,16 +48,16 @@ In below scenario, we are going to run Acumos A and Acumos B for testing locally
 Launching
 ~~~~~~~~~
 
-Start two microservice instances for development and testing like this::
+Start two microservice instances for development and testing as follows, with the appropriate version numbers::
 
     java -Djavax.net.ssl.trustStore=src/test/resources/acumosTrustStore.jks \
          -Djavax.net.ssl.trustStorePassword=acumos \
-         -jar target/federated-gateway-1.0.0-SNAPSHOT.jar \
+         -jar target/gateway-1.x.y-SNAPSHOT.jar \
          --spring.profiles.active="default,acumosa" 
 
     java -Djavax.net.ssl.trustStore=src/test/resources/acumosTrustStore.jks \
          -Djavax.net.ssl.trustStorePassword=acumos \
-         -jar target/federated-gateway-1.0.0-SNAPSHOT.jar \
+         -jar target/gateway-1.x.y-SNAPSHOT.jar \
          --spring.profiles.active="default,acumosb"
 
 
index 3448620..121e8a5 100644 (file)
@@ -1,8 +1,8 @@
-federation.instance=adapter
-federation.instance.name=test
-#federation.instance=gateway
-#federation.instance.name=acumosa
-
+#federation.instance=adapter
+#federation.instance.name=test
+federation.instance=gateway
+federation.instance.name=acumosa
+federation.operator=1
 federation.address = 10.0.2.67
 federation.server.port = 9001
 federation.ssl.key-store = classpath:acumosa.pkcs12
index c15e0d4..ba57ff9 100644 (file)
@@ -1,9 +1,9 @@
 #pretend we are an adapter so that we can use local peer config
-federation.instance=adapter
-federation.instance.name=test
-#federation.instance=gateway
-#federation.instance.name=acumosb
-
+#federation.instance=adapter
+#federation.instance.name=test
+federation.instance=gateway
+federation.instance.name=acumosb
+federation.operator=1
 federation.address = 10.0.2.67
 federation.server.port = 9002
 federation.ssl.key-store = classpath:acumosb.pkcs12
index be83485..5e24839 100644 (file)
@@ -1,26 +1,19 @@
 <?xml version="1.0"?>
-<!--
-===============LICENSE_START=======================================================
-Acumos Apache-2.0
-===================================================================================
-Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-===================================================================================
-This Acumos software file is distributed by AT&T and Tech Mahindra
-under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-This file is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-===============LICENSE_END=========================================================
--->
+<!-- ===============LICENSE_START======================================================= 
+       Acumos Apache-2.0 =================================================================================== 
+       Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights 
+       reserved. =================================================================================== 
+       This Acumos software file is distributed by AT&T and Tech Mahindra under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 This file is distributed on 
+       an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 
+       or implied. See the License for the specific language governing permissions 
+       and limitations under the License. ===============LICENSE_END========================================================= -->
 <project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-       xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+       xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.acumos.federation</groupId>
        <artifactId>gateway</artifactId>
@@ -46,12 +39,11 @@ limitations under the License.
                <skipTests>false</skipTests>
                <!-- dependencies versions -->
                <logback.version>1.2.3</logback.version>
-                <springfox.version>2.7.0</springfox.version>
+               <springfox.version>2.7.0</springfox.version>
                <!-- Not supplied to all jobs; e.g., Javadoc -->
                <docker.pull.registry>nexus3.acumos.org:10001</docker.pull.registry>
                <!-- Supplied by Jenkins -->
                <docker.push.registry>${env.NEXUS3_PUSH_REGISTRY}</docker.push.registry>
-               <maven.build.timestamp.format>yyyy.MM.dd_HH.mm</maven.build.timestamp.format>
        </properties>
 
        <!-- Some dependencies are specific to Acumos, but this POM defines no repositories 
@@ -74,7 +66,8 @@ limitations under the License.
                <dependency>
                        <groupId>org.json</groupId>
                        <artifactId>json</artifactId>
-                       <version>20160212</version>
+                       <!-- Override Spring-boot choice -->
+                       <version>20160212</version><!--$NO-MVN-MAN-VER$-->
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
@@ -169,15 +162,15 @@ limitations under the License.
                        <version>3.6</version>
                </dependency>
                <dependency>
-       <groupId>org.apache.commons</groupId>
-       <artifactId>commons-compress</artifactId>
-       <version>1.5</version>
+                       <groupId>org.apache.commons</groupId>
+                       <artifactId>commons-compress</artifactId>
+                       <version>1.5</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
                <dependency>
                        <groupId>commons-beanutils</groupId>
                        <artifactId>commons-beanutils</artifactId>
-                       <version>1.9.3</version>
+                       <!-- spring sets the <version>1.9.3</version> -->
                </dependency>
                <dependency>
                        <groupId>com.github.docker-java</groupId>
@@ -187,7 +180,7 @@ limitations under the License.
                <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
-                       <version>1.8.13</version>
+                       <!-- spring sets the <version>1.8.13</version> -->
                </dependency>
                <dependency>
                        <groupId>org.assertj</groupId>
@@ -253,7 +246,7 @@ limitations under the License.
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-dependency-plugin</artifactId>
-                               <version>2.10</version>
+                               <!-- spring sets the <version>2.10</version> -->
                                <executions>
                                        <execution>
                                                <id>copy-dependencies</id>
@@ -382,8 +375,7 @@ limitations under the License.
                                        <processEndTag>===============LICENSE_END=========================================================</processEndTag>
                                        <sectionDelimiter>===================================================================================</sectionDelimiter>
                                        <inceptionYear>2017</inceptionYear>
-                                       <organizationName>AT&amp;T Intellectual Property &amp; Tech
-                                               Mahindra. All rights reserved.</organizationName>
+                                       <organizationName>AT&amp;T Intellectual Property &amp; Tech Mahindra. All rights reserved.</organizationName>
                                        <projectName>Acumos</projectName>
                                        <canUpdateCopyright>true</canUpdateCopyright>
                                        <canUpdateDescription>true</canUpdateDescription>
index b0a3703..041a96e 100644 (file)
   <property name="generalLogName" value="application" />
   <property name="errorLogName" value="error" />
   <property name="debugLogName" value="debug" />
-<!-- 
-  <property name="defaultPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
-  <property name="debugLoggerPattern" value="%date{ISO8601}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
--->
-       <property name="defaultPattern"
-               value="%date{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;,UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
-       <property name="debugLoggerPattern"
-               value="%date{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;,UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
-       <!-- This basic audit pattern uses begin/end parameters instead of current time, otherwise identical to default -->
-       <property name="auditLoggerPattern"
-               value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
-  <!-- Example evaluator filter applied against console appender -->
+
+       <!-- From https://wiki.acumos.org/display/OAM/Log+Standards -->
+       <property name="LogTimestamp"   value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+       <property name="Level"          value="%.-5level"/>
+       <property name="Logger"         value="%logger"/>
+       <property name="Mdc"            value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}"/>
+       <property name="Message"        value="%replace(%replace(%msg){'\t','\\\\t'}){'\n','\\\\n'}"/>
+       <property name="RootException"  value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+       <property name="Marker"         value="%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}"/>
+       <property name="Thread"         value="%thread"/>
+       <property name="p_1_LogTimestamp"       value="${LogTimestamp}" />
+       <property name="p_2_EntryTimestamp"     value="%X{EntryTimestamp}" />
+       <property name="p_3_InvokeTimestamp"    value="%X{InvokeTimestamp}" />
+       <property name="p_4_RequestID"          value="%X{RequestID}" />
+       <property name="p_5_InvocationID"       value="%X{InvocationId}" />
+       <property name="p_6_InstanceID"         value="%X{InstanceUUID}" /> <!--  previously InstanceUUID -->
+       <property name="p_7_ServiceInstanceID"  value="%X{ServiceInstanceId}" />
+       <property name="p_8_thread"             value="$%thread}" />
+       <property name="p_9_ServiceName"        value="%X{ServiceName}" />
+       <property name="p_10_PartnerName"       value="%X{PartnerName}" />
+       <property name="p_11_StatusCode"        value="%X{StatusCode}" />
+       <property name="p_12_ResponseCode"      value="%X{ResponseCode}" />
+       <property name="p_13_ResponseDesc"      value="%X{ResponseDesc}" />
+       <property name="p_14_level"             value="${Level}" />
+       <property name="p_15_Severity"          value="%X{Severity}" />
+       <property name="p_16_ServerIPAddress"   value="%X{ServerIPAddress}" />
+       <property name="p_17_ElapsedTime"       value="%X{ElapsedTime}" />
+       <property name="p_18_ServerFQDN"        value="%X{ServerFQDN}" />
+       <property name="p_19_ClientIPAddress"   value="%X{ClientIPAddress}" />
+       <property name="p_20_VirtualServerName" value="%X{VirtualServerName}" />
+       <property name="p_21_ContextName"       value="%X{ContextName}" />
+       <property name="p_22_TargetEntity"      value="%X{TargetEntity}" />
+       <property name="p_23_TargetServiceName" value="%X{TargetServiceName}" />
+       <property name="p_24_TargetElement"     value="%X{TargetElement}" />
+       <property name="p_25_User"              value="%X{User}" />
+       <property name="p_26_logger"            value="${Logger}" />
+       <property name="p_27_mdc"               value="${Mdc}" />
+       <property name="p_27_no_mdc"            value="%X{DO_NOT_REPEAT_MDC}" /> <!-- a no-op -->
+       <property name="p_28_message"           value="${Message}" />
+       <property name="p_29_marker"            value="${Marker}" />
+       <property name="singleLineAthenaPattern" value="%nopexception${p_1_LogTimestamp}|${p_2_EntryTimestamp}|${p_3_InvokeTimestamp}|${p_4_RequestID}|${p_5_InvocationID}|${p_6_InstanceID}|${p_7_ServiceInstanceID}|${p_8_thread}|${p_9_ServiceName}|${p_10_PartnerName}|${p_11_StatusCode}|${p_12_ResponseCode}|${p_13_ResponseDesc}|${p_14_level}|${p_15_Severity}|${p_16_ServerIPAddress}|${p_17_ElapsedTime}|${p_18_ServerFQDN}|${p_19_ClientIPAddress}|${p_20_VirtualServerName}|${p_21_ContextName}|${p_22_TargetEntity}|${p_23_TargetServiceName}|${p_24_TargetElement}|${p_25_User}|${p_26_logger}|${p_27_no_mdc}|${p_28_message}|${p_29_marker}%n" />
+
+       <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}" />
+       <property name="p_thr" value="%thread" />
+       <property name="p_lvl" value="%level" />
+       <property name="p_log" value="%logger" />
+       <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}" />
+       <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}" />
+       <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}" />
+       <property name="p_mrk" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}" />
+       <property name="singleLineBoreasPattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mrk}\t%n" />
+       <property name="multiLineBoreasPattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t%mdc\t%msg\t%rootException\t%marker\t%n" />
+
+       <!-- Passes only events with level WARN or above -->
+       <appender name="console-warn" class="ch.qos.logback.core.ConsoleAppender">
+               <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+                       <level>WARN</level>
+               </filter>
+               <encoder>
+                       <pattern>${singleLineAthenaPattern}</pattern>
+               </encoder>
+       </appender>
+
   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
-      <pattern>${defaultPattern}</pattern>
+      <pattern>${singleLineAthenaPattern}</pattern>
     </encoder>
   </appender>    
     
     <file>${logDirectory}/${generalLogName}.log</file>
     <rollingPolicy
       class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
-      <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip
-      </fileNamePattern>
+      <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip</fileNamePattern>
       <minIndex>1</minIndex>
       <maxIndex>9</maxIndex>
     </rollingPolicy>
       <maxFileSize>5MB</maxFileSize>
     </triggeringPolicy>
     <encoder>
-      <pattern>${defaultPattern}</pattern>
+      <pattern>${singleLineAthenaPattern}</pattern>
     </encoder>
   </appender>
   
     <file>${logDirectory}/${errorLogName}.log</file>
     <rollingPolicy
       class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
-      <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip
-      </fileNamePattern>
+      <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip</fileNamePattern>
       <minIndex>1</minIndex>
       <maxIndex>9</maxIndex>
     </rollingPolicy>
       <maxFileSize>5MB</maxFileSize>
     </triggeringPolicy>
     <encoder>
-      <pattern>${defaultPattern}</pattern>
+      <pattern>${singleLineAthenaPattern}</pattern>
     </encoder>
   </appender>
   
     <file>${debugLogDirectory}/${debugLogName}.log</file>
     <rollingPolicy
       class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
-      <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip
-      </fileNamePattern>
+      <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip</fileNamePattern>
       <minIndex>1</minIndex>
       <maxIndex>9</maxIndex>
     </rollingPolicy>
       <maxFileSize>5MB</maxFileSize>
     </triggeringPolicy>
     <encoder>
-      <pattern>${debugLoggerPattern}</pattern>
+      <pattern>${singleLineAthenaPattern}</pattern>
     </encoder>
   </appender>
   
   
   <root level="info">
                <appender-ref ref="asyncEELF" />
-               <appender-ref ref="STDOUT" />
+               <appender-ref ref="console-warn" />
        </root>
 
   <!-- ============================================================================ -->