{"id":42861712,"url":"https://github.com/link-nv/logback-s3-rolling-policy","last_synced_at":"2026-01-30T12:38:27.638Z","repository":{"id":34983065,"uuid":"39064821","full_name":"link-nv/logback-s3-rolling-policy","owner":"link-nv","description":"Logback RollingPolicy to store logs in S3","archived":false,"fork":false,"pushed_at":"2025-10-03T10:30:30.000Z","size":375,"stargazers_count":34,"open_issues_count":208,"forks_count":41,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-03T12:25:00.441Z","etag":null,"topics":["logback","logback-rolling-policy","s3-bucket"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/link-nv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-07-14T09:03:08.000Z","updated_at":"2025-06-04T20:51:30.000Z","dependencies_parsed_at":"2023-02-17T09:31:29.374Z","dependency_job_id":"6b8064e8-7d8a-4d8a-b126-65d0f37b8e0f","html_url":"https://github.com/link-nv/logback-s3-rolling-policy","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/link-nv/logback-s3-rolling-policy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-nv%2Flogback-s3-rolling-policy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-nv%2Flogback-s3-rolling-policy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-nv%2Flogback-s3-rolling-policy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-nv%2Flogback-s3-rolling-policy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/link-nv","download_url":"https://codeload.github.com/link-nv/logback-s3-rolling-policy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link-nv%2Flogback-s3-rolling-policy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28912913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logback","logback-rolling-policy","s3-bucket"],"created_at":"2026-01-30T12:38:27.563Z","updated_at":"2026-01-30T12:38:27.628Z","avatar_url":"https://github.com/link-nv.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Logback RollingPolicy with S3 upload\n====================================\n\nlogback-s3-rolling-policy automatically uploads rolled log files to S3.\n\nThere are 2 rolling policies which can be used:\n* `S3FixedWindowRollingPolicy`\n* `S3TimeBasedRollingPolicy`\n\nlogback-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.\n\nIndex\n-----\n\n* [Requirements](#requirements) \n* [Usage](#usage) \n* [Configuration](#configuration) \n  * [logback.xml variables](#logbackxml-variables) \n  * [web.xml](#webxml) \n  * [logback.xml rolling policy examples](#logbackxml-rolling-policy-examples) \n* [AWS Credentials](#aws-credentials) \n* [Libraries](#libraries) \n\nRequirements\n------------\n\n* Java 1.7+\n\nConfiguration\n-------------\n\n### logback.xml variables\n\nWhether you implement one of any available S3 policies, the following extra variables (on top of Logback's) can be used:\n\n* `s3BucketName` The S3 bucket name to upload your log files to (mandatory).\n* `awsAccessKey` Your AWS access key. If not provided it falls back to the AWS SDK default provider chain.\n* `awsSecretKey` Your AWS secret key. If not provided it falls back to the AWS SDK default provider chain.\n* `s3FolderName` The S3 folder name in your S3 bucket to put the log files in. This variable supports dates, just put your [pattern](https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html) between `%d{}`. Example: `%d{yyyy/MM/dd}`.\n* `shutdownHookType` Defines which type of shutdown hook you want to use. This variable is mandatory when you use `rolloverOnExit`. Defaults to `NONE`. Possible values are:\n  * `NONE` This will not add a shutdown hook. Please note that your most up to date log file won't be uploaded to S3!\n  * `JVM_SHUTDOWN_HOOK` This will add a runtime shutdown hook. If you're using a webapplication, please use the `SERVLET_CONTEXT`, as the JVM shutdown hook is not really safe to use here.\n  * `SERVLET_CONTEXT` This will register a shutdown hook to the context destroyed method of `RollingPolicyContextListener`. Don't forget to actually add the context listener to you `web.xml`. (see below)\n* `rolloverOnExit` Whether to rollover when your application is being shut down or not. Boolean value, defaults to `false`. If this is set to `false`, and you have defined a `shutdownHookType`, then the log file will be uploaded as is.\n* `prefixTimestamp` Whether to prefix the uploaded filename with a timestamp formatted as `yyyyMMdd_HHmmss` or not. Boolean value, defaults to `false`.\n* `prefixIdentifier` Whether to prefix the uploaded filename with an identifier or not. Boolean value, defaults to `false`. If running on an AWS EC2 instance, the instance ID will be used. If not running on an AWS EC2 instance, the hostname address will be used. If the hostname address can't be used, a UUID will be used. \n\n### web.xml\n\nIf you're using the shutdown hook `SERVLET_CONTEXT` as defined above, you'll need to add the context listener class to your `web.xml`:\n\n```xml\n\u003clistener\u003e\n   \u003clistener-class\u003ech.qos.logback.core.rolling.shutdown.RollingPolicyContextListener\u003c/listener-class\u003e\n\u003c/listener\u003e\n```\n\n### Run-time variables\n\nAs of version `1.3` you can set run-time variables. For now you can only add an extra S3 folder.\n\nJust 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.\n\n### logback.xml rolling policy examples\n\nAn example `logback.xml` appender for each available policy using `RollingFileAppender`.\n\n* `ch.qos.logback.core.rolling.S3FixedWindowRollingPolicy`:  \n```xml\n\u003cappender name=\"FILE\" class=\"ch.qos.logback.core.rolling.RollingFileAppender\"\u003e\n  \u003cfile\u003elogs/myapp.log\u003c/file\u003e\n  \u003cencoder\u003e\n    \u003cpattern\u003e[%d] %-8relative %22c{0} [%-5level] %msg%xEx{3}%n\u003c/pattern\u003e\n  \u003c/encoder\u003e\n  \u003crollingPolicy class=\"ch.qos.logback.core.rolling.S3FixedWindowRollingPolicy\"\u003e\n    \u003cfileNamePattern\u003elogs/myapp.%i.log.gz\u003c/fileNamePattern\u003e\n    \u003cawsAccessKey\u003eACCESS_KEY\u003c/awsAccessKey\u003e\n    \u003cawsSecretKey\u003eSECRET_KEY\u003c/awsSecretKey\u003e\n    \u003cs3BucketName\u003emyapp-logging\u003c/s3BucketName\u003e\n    \u003cs3FolderName\u003elogs/%d{yyyy/MM/dd}\u003c/s3FolderName\u003e\n    \u003crolloverOnExit\u003etrue\u003c/rolloverOnExit\u003e\n    \u003cshutdownHookType\u003eSERVLET_CONTEXT\u003c/shutdownHookType\u003e\n    \u003cprefixTimestamp\u003etrue\u003c/prefixTimestamp\u003e\n    \u003cprefixIdentifier\u003etrue\u003c/prefixIdentifier\u003e\n  \u003c/rollingPolicy\u003e\n  \u003ctriggeringPolicy class=\"ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy\"\u003e\n    \u003cmaxFileSize\u003e10MB\u003c/maxFileSize\u003e\n  \u003c/triggeringPolicy\u003e\n\u003c/appender\u003e\n```\nIn this example you'll find the logs at `myapp-logging/logs/2015/08/18/`.\n\n* `ch.qos.logback.core.rolling.S3TimeBasedRollingPolicy`:  \n```xml\n\u003cappender name=\"FILE\" class=\"ch.qos.logback.core.rolling.RollingFileAppender\"\u003e\n  \u003cfile\u003elogs/myapp.log\u003c/file\u003e\n  \u003cencoder\u003e\n    \u003cpattern\u003e[%d] %-8relative %22c{0} [%-5level] %msg%xEx{3}%n\u003c/pattern\u003e\n  \u003c/encoder\u003e\n  \u003crollingPolicy class=\"ch.qos.logback.core.rolling.S3TimeBasedRollingPolicy\"\u003e\n    \u003c!-- Rollover every minute --\u003e\n    \u003cfileNamePattern\u003elogs/myapp.%d{yyyy-MM-dd_HH-mm}.%i.log.gz\u003c/fileNamePattern\u003e\n    \u003cawsAccessKey\u003eACCESS_KEY\u003c/awsAccessKey\u003e\n    \u003cawsSecretKey\u003eSECRET_KEY\u003c/awsSecretKey\u003e\n    \u003cs3BucketName\u003emyapp-logging\u003c/s3BucketName\u003e\n    \u003cs3FolderName\u003elog\u003c/s3FolderName\u003e\n    \u003crolloverOnExit\u003etrue\u003c/rolloverOnExit\u003e\n    \u003cshutdownHookType\u003eSERVLET_CONTEXT\u003c/shutdownHookType\u003e\n    \u003cprefixTimestamp\u003efalse\u003c/prefixTimestamp\u003e\n    \u003cprefixIdentifier\u003etrue\u003c/prefixIdentifier\u003e\n    \u003ctimeBasedFileNamingAndTriggeringPolicy class=\"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP\"\u003e\n      \u003cmaxFileSize\u003e10MB\u003c/maxFileSize\u003e\n    \u003c/timeBasedFileNamingAndTriggeringPolicy\u003e\n  \u003c/rollingPolicy\u003e\n\u003c/appender\u003e\n```\nIn this example you'll find the logs at `myapp-logging/log/`.\n\n### AWS Credentials\n\nIt is a good idea to create an IAM user only allowed to upload S3 object to a specific S3 bucket.\nIt improves the control and reduces the risk of unauthorized access to your S3 bucket.\n\nThe following is an example IAM policy.\n```json\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Action\": [\n        \"s3:PutObject\"\n      ],\n      \"Sid\": \"Stmt1378251801000\",\n      \"Resource\": [\n        \"arn:aws:s3:::myapp-logging/log/*\"\n      ],\n      \"Effect\": \"Allow\"\n    }\n  ]\n}\n```\n\nLibraries\n---------\n\nThis project uses the following libraries:\n* `com.amazonaws:aws-java-sdk:1.11.7`\n* `ch.qos.logback:logback-classic:1.2.3`\n* `com.google.guava:guava:18.0`\n* `javax.servlet:servlet-api:2.4` (scope provided)\n* `org.jetbrains:annotations:15.0` (scope provided)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-nv%2Flogback-s3-rolling-policy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flink-nv%2Flogback-s3-rolling-policy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink-nv%2Flogback-s3-rolling-policy/lists"}