title: How to send log4j2 generated log files to AWS cloudwatch and S3 bucket
body: <p>I have two log4j2 generated log files. I am generating these log files using FileAppender and now I want to send those log files to AWS cloudwatch and S3 bucket as a log4j2 destination.</p>
  
  <p>I am new to log4j2 and this cloud API. I have searched a lot but not able to find something useful. Though I have found these two links:</p>
  
  <p><a href="http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-configuration-cwl.html" rel="nofollow">http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-configuration-cwl.html</a> and <a href="http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-logging.html" rel="nofollow">http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-logging.html</a></p>
  
  <p>But I am not sure how it will work and whether Is this the only way to send log files to AWS cloudwatch and S3 bucket. And What other settings do I need to do in my log4j2.xml file.</p>
  
  <p>So, how to send log4j2 generated log files to cloud API? I have to use log4j2 and J2EE.</p>
  
  <p>Here is my log4j2.xml file:</p>
  
  <pre><code>&lt;Configuration monitorInterval="30" status="warn" name= "MyApp" packages="" xmlns="http://logging.apache.org/log4j/2.0/config"&gt;
  
  &lt;Properties&gt;
      &lt;Property name="filename-server1-all"&gt;${sys:catalina.home}/logs/server1-all.log&lt;/Property&gt;
      &lt;Property name="filename-server1-err"&gt;${sys:catalina.home}/logs/app.log&lt;/Property&gt;
      &lt;Property name="pattern_layout"&gt;%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n&lt;/Property&gt;
  &lt;/Properties&gt;
  
  &lt;Appenders&gt;
      &lt;Console name="STDOUT" target="SYSTEM_OUT"&gt;
          &lt;PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/&gt;
      &lt;/Console&gt;
  
      &lt;File name="appender-server-1-all" fileName="${filename-server1-all}"&gt;
          &lt;PatternLayout pattern="${pattern_layout}" /&gt;
      &lt;/File&gt;
  
      &lt;File name="appender-server1-err" fileName="${filename-server1-err}"&gt;
          &lt;PatternLayout pattern="${pattern_layout}" /&gt;
      &lt;/File&gt;
   &lt;/Appenders&gt;
  
         &lt;Loggers&gt;
          &lt;Root level="trace"&gt;
              &lt;AppenderRef ref="STDOUT"/&gt;
              &lt;AppenderRef ref="appender-server-1-all" level="all"/&gt;
              &lt;AppenderRef ref="appender-server1-err" level="error"/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
     &lt;/Configuration&gt;
  </code></pre>