Add file appender to test logback config 30/3230/1
authorLott, Christopher (cl778h) <cl778h@att.com>
Tue, 23 Oct 2018 17:33:40 +0000 (13:33 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Tue, 23 Oct 2018 17:33:40 +0000 (13:33 -0400)
Change-Id: I876267a6637eac64efa7db93f4a65a1c9dcf9e27
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
gateway/src/test/resources/logback.xml

index c80b6b8..0862a18 100644 (file)
 
 <configuration>
 
-       <!-- Basic logback configuration for the Common Data Service client
-               ONLY FOR DEV AND TEST - this file is not packaged with the jar. -->
+       <!-- Basic logback configuration for FOR DEV AND TEST only -->
 
-       <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-               <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder 
-                       by default -->
+       <!-- component name is log file basename -->
+       <property name="componentName" value="federation-gateway"></property>
+       <!-- gather files in a subdirectory - usually a volume in docker -->
+       <property name="logDirectory" value="logs/${componentName}" />
+       <!-- basic pattern -->
+       <property name="pattern" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC} [%thread] %-5level %logger{36} - %msg%n"/>
+
+       <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+               <!-- defaults to type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+               <encoder>
+                       <pattern>${pattern}</pattern>
+               </encoder>
+       </appender>
+
+       <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+               <file>${logDirectory}/${componentName}.log</file>
+               <append>true</append>
+               <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+                       <fileNamePattern>${logDirectory}/${componentName}.%i.log.zip</fileNamePattern>
+                       <minIndex>1</minIndex>
+                       <maxIndex>5</maxIndex>
+               </rollingPolicy>
+               <triggeringPolicy
+                       class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+                       <maxFileSize>1MB</maxFileSize>
+               </triggeringPolicy>
+               <!-- defaults to type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
                <encoder>
-                       <pattern>%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC} [%thread] %-5level %logger{36} - %msg%n
-                       </pattern>
+                       <pattern>${pattern}</pattern>
                </encoder>
        </appender>
 
+       <!-- Set default level for all loggers -->
        <root level="INFO">
-               <appender-ref ref="console" />
+               <appender-ref ref="CONSOLE" />
+               <appender-ref ref="FILE" />
        </root>
 
-       <!-- Apache HttpClient has verbose debug output; silence it -->
-       <logger name="org.apache.http" level="INFO" />
-
-       <!-- Spring client has verbose debug output; silence it -->
-       <logger name="org.springframework.web.client" level="INFO" />
+       <!-- Code under test should be chatty --> >
+       <logger name="org.acumos.federation.gateway" level="DEBUG" />
 
 </configuration>