AOEpeople/logback-s3-rolling-policy

Name: logback-s3-rolling-policy

Owner: AOE

Description: Logback RollingPolicy to store logs in S3

Forked from: SiteFlo/logback-s3-rolling-policy

Created: 2017-06-01 09:25:04.0

Updated: 2017-06-01 09:25:06.0

Pushed: 2017-06-01 09:51:02.0

Homepage: null

Size: 117

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Logback RollingPolicy with S3 upload

logback-s3-rolling-policy automatically uploads rolled log files to S3.

There are 2 rolling policies which can be used:

logback-s3-rolling-policy was forked from logback-s3 (https://github.com/shuwada/logback-s3) but transfered into a new project because changes were getting too big.

Index
Requirements
Usage

Add the linkID repositories to your pom file:

 REMOTE ARTIFACT REPOSITORIES -->
ositories>
<repository>
    <id>repo.linkid.be.release</id>
    <name>LinkID Public Repository</name>
    <url>http://repo.linkid.be/releases</url>
    <snapshots>
        <enabled>false</enabled>
        <updatePolicy>never</updatePolicy>
    </snapshots>
    <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
    </releases>
</repository>
<repository>
    <id>repo.linkid.be.snapshot</id>
    <name>LinkID Public Repository</name>
    <url>http://repo.linkid.be/snapshots</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
    <releases>
        <enabled>false</enabled>
        <updatePolicy>never</updatePolicy>
    </releases>
</repository>
positories>

Add the logback-s3-rolling-policy dependency to your pom file:

endency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-s3-rolling-policy</artifactId>
<version>1.5</version>
pendency>
Configuration
logback.xml variables

Whether you implement one of any available S3 policies, the following extra variables (on top of Logback's) are mandatory:

There are few optional variables:

web.xml

If you're using the shutdown hook SERVLET_CONTEXT as defined above, you'll need to add the context listener class to your web.xml:

tener>
listener-class>ch.qos.logback.core.rolling.shutdown.RollingPolicyContextListener</listener-class>
stener>
Run-time variables

As of version 1.3 you can set run-time variables. For now you can only add an extra S3 folder.

Just use CustomData.extraS3Folder.set( "extra_folder_name" ); somewhere in your code before the upload occurs. You can always change this value during run-time and it will be picked up on the next upload. set to null to ignore.

logback.xml rolling policy examples

An example logback.xml appender for each available policy using RollingFileAppender.

AWS Credentials

It is a good idea to create an IAM user only allowed to upload S3 object to a specific S3 bucket. It improves the control and reduces the risk of unauthorized access to your S3 bucket.

The following is an example IAM policy.


ersion": "2012-10-17",
tatement": [
{
  "Action": [
    "s3:PutObject"
  ],
  "Sid": "Stmt1378251801000",
  "Resource": [
    "arn:aws:s3:::myapp-logging/log/*"
  ],
  "Effect": "Allow"
}


Libraries

This project uses the following libraries:

Publish to Artifactory

For now we only have a manual way to publish this to Artifactory


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.