AWS Latency request log handler
Description
This library exposes a simple but very efficient AWS request handler that log in a text files various details about your AWS calls.
How to use it
i. Declare the dependency in your pom.xml file.
<dependency>
<groupId>cloud.cirrusup</groupId>
<artifactId>aws-latency-request-log-handler</artifactId>
<version>1.1.0</version>
</dependency>
ii. Create a request handler object.
AwsLatencyRequestLogHandler handler = new AwsLatencyRequestLogHandler();
If you want to publish call details in JSON format, then declare the handler in the following manner:
AwsLatencyRequestLogHandler handler = new AwsLatencyRequestLogHandler(new JSONPublisher());
iii. Enhance the AWS client with the request handler created above.
amazonS3Client.addRequestHandler(handler);
iv. Create a log appender named aws-latency-log.
<appender name="AWS-APPENDER-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/awsLatency.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- hourly rollover -->
<fileNamePattern>/var/log/awsLatency/awsLatency.%d{yyyy-MM-dd-HH}.log</fileNamePattern>
<!-- keep 2 days' worth of history capped at 500MB total size -->
<maxHistory>2</maxHistory>
<totalSizeCap>500MB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>[%thread] %-5level - %d{yyyy-MM-dd HH:mm:ss} - %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%thread] %-5level - %d{yyyy-MM-dd HH:mm:ss} - %logger{36} - %msg%n</pattern>
</encoder>
</appender>