title: Store app logs in AWS Cloudwatch using Log4J appender
body: <p>I'm trying to store application-level logs in AWS Cloudwatch logs from Java Web application.</p>
  
  <p>My sample Java Web application is already having Log4J implementation. So without writing AWS SDK code, I just want to push logs to Cloudwatch. I just came across Log4J cloudwatch appender.</p>
  
  <p>Followed this link but  not sure how to configure AWS authentications(access/secret Keys, regions)
  <a href="https://dzone.com/articles/announcing-log4j-aws-appenders" rel="nofollow noreferrer">https://dzone.com/articles/announcing-log4j-aws-appenders</a></p>
  
  <p><strong>log4j.properties</strong></p>
  
  <pre><code>log4j.rootLogger=WARN, console
  
  log4j.logger.org.apache.http=ERROR
  log4j.logger.com.amazonaws=ERROR
  log4j.logger.com.mkyong=ERROR
  log4j.additivity.com.mkyong=true
  
  log4j.appender.console=org.apache.log4j.ConsoleAppender
  log4j.appender.console.layout=org.apache.log4j.PatternLayout
  log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
  
  log4j.appender.cloudwatch=com.kdgregory.log4j.aws.CloudWatchAppender
  log4j.appender.cloudwatch.layout=org.apache.log4j.PatternLayout
  log4j.appender.cloudwatch.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
  
  log4j.appender.cloudwatch.logGroup=ExampleCloudwatchLog
  log4j.appender.cloudwatch.logStream={startupTimestamp}-{sequence}
  log4j.appender.cloudwatch.batchDelay=2500
  log4j.appender.cloudwatch.rotationMode=daily
  </code></pre>
  
  <p>Looks like credentials are not read from my local machine which I configured using <code>aws configure</code>.</p>
  
  <p><strong>Note:</strong> Application would be deployed on AWS or non-AWS environments also. So not sure about setting up the AWS IAM role also.</p>
  
  <p>Could anyone help me with passing the credentials of AWS? </p>