title: AWS CloudWatch logging with Spring Boot
body: <p>What should be the approach to store logs of multiple spring boot application(s) in cloud watch?</p>
  
  <p>Sample spring-boot - logback-spring.xml configuration file is below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;property name="LOGS" value="/logs/abc/" /&gt;
  
  &lt;appender name="Console" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
          &lt;Pattern&gt; %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable &lt;/Pattern&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
      &lt;file&gt;${LOGS}/abc-log.log&lt;/file&gt;
      &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt; 
      &lt;Pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/Pattern&gt; &lt;/encoder&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
          &lt;!-- rollover daily and when the file reaches 10 MegaBytes --&gt;
          &lt;fileNamePattern&gt;${LOGS}/archived/abc-log-%d{yyyy-MM-dd}.%i.log
          &lt;/fileNamePattern&gt;
          &lt;timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
              &lt;maxFileSize&gt;5MB&lt;/maxFileSize&gt;
          &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
          &lt;maxHistory&gt;2&lt;/maxHistory&gt;
          &lt;totalSizeCap&gt;10MB&lt;/totalSizeCap&gt;
      &lt;/rollingPolicy&gt;
  &lt;/appender&gt;
  
  &lt;!-- LOG everything at INFO level --&gt;
  &lt;root level="info"&gt;
      &lt;appender-ref ref="RollingFile" /&gt;
      &lt;appender-ref ref="Console" /&gt;
  &lt;/root&gt;
  
  &lt;logger name="com.abc" level="trace" additivity="false"&gt;
      &lt;appender-ref ref="RollingFile" /&gt;
      &lt;appender-ref ref="Console" /&gt;
  &lt;/logger&gt;
  </code></pre>
  
  <p></p>