Appenders for Log4J 1.x that write to various AWS destinations:
- CloudWatch Logs: basic logging that allows keyword search and time ranges.
- Kinesis Streams: the first step in a logging pipeline that ends in Elasticsearch.
- SNS: useful for real-time error notifications.
In addition to the appenders, this library includes:
- JsonLayout, which lets you send data to an Elasticsearch/Kibana cluster without the need for parsing.
- StatisticsMBean, which allows the appenders to report operational data via JMX.
To use these appenders, include the
aws-appenders JAR in your project along with Log4J
and the relevant AWS JAR(s), then configure the desired appender in your Log4J properties.
Each appender's documentation describes the complete set of configuration properties and
shows a typical configuration.
There is also an example project that exercises all of the appenders.
Getting the JAR
Released versions of the appenders are uploaded to Maven Central. You can find them here.
I follow the standard
MAJOR.MINOR.PATCH versioning scheme:
MAJORis currently 1. I am considering support for additional logging frameworks, at which point it will change to 2.
MINORis incremented for each change that adds signficant functionality or changes the behavior of existing functionality in non-backwards-compatible ways. The API does not break backwards compatibility for minor releases, so your configurations can remain the same.
PATCHis incremented for reflect bugfixes or additional features that don't change the existing behavior (although they may add behavior).
To avoid dependency hell, all dependencies are marked as "provided": you will need to ensure that your project includes necessary dependencies, as follows:
aws-java-sdk-ststo use the
aws:accountIdsubstitution variable (typically used with
The minimum supported dependency versions are:
- JDK: 1.6 The build script generates 1.6-compatible classfiles, and the appender code does not rely on standard libary classes/methods introduced after 1.6. As-of this release, I have verified that I can run (but not build) the example program using OpenJDK 1.6. Beware, however: Amazon releases the SDK on a daily basis, and a newer release may require a later JVM.
- Log4J: 1.2.16
This is the first version that implements
LoggingEvent.getTimeStamp(), which is needed to order messages when sending to AWS. It's been around since 2010, so if you haven't upgraded already you should.
- AWS SDK: 1.11.0 The appenders will work with all releases in the 1.11.x sequence. If you're using a version that has client builders, they will be used to create service clients; if not, the default client constructors will be used. For more information, see the FAQ.
I have made an intentional effort to limit dependencies to the bare minimum. This has in some cases meant that I write internal implementations for functions that are found in common libraries.