I'm trying to store application-level logs in AWS Cloudwatch logs from Java Web application.
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.
Followed this link but not sure how to configure AWS authentications(access/secret Keys, regions) https://dzone.com/articles/announcing-log4j-aws-appenders
log4j.properties
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
Looks like credentials are not read from my local machine which I configured using aws configure.
Note: Application would be deployed on AWS or non-AWS environments also. So not sure about setting up the AWS IAM role also.
Could anyone help me with passing the credentials of AWS?
Thanks for your valuable replay @kdgregory.
The troubleshooting guide really helped me a lot.
Enabled debugging using below and found dependency not resolved.
Finally, I achieved by adding AWS ADK logs dependencies in pom. Works fine.
Thanks,