Reputation: 1020
I have a daemon in Scala running on EC2 that processes jobs. For each job I know a (possibly) different log stream I'd like to append messages to.
How can I make a log-stream specific Appender that I can attach to my log4j logger, and change it when my listener moves on to the next job?
Upvotes: 11
Views: 1752
Reputation: 1483
This type of integration is blended of different things like AWS Java API, Log4J API, and AWS Cloud Watch configurations.
You can achieve that by implementing a customized log4j appender. An example you may leverage from github is the following link.
The idea is to add the log4j appender class to your source project and use it with your log4j library. The appender will use AWS CloudWatch API to append the logs for a specific log stream and log group that you need to create on AWS account.
Example: CloudwatchAppender.java
Every log your program creates will send a cloud watch event.
Upvotes: 1