{"id":19212056,"url":"https://github.com/joedborg/charm-logrotate-reactive","last_synced_at":"2026-07-29T08:31:29.600Z","repository":{"id":145095003,"uuid":"161359590","full_name":"joedborg/charm-logrotate-reactive","owner":"joedborg","description":"Provides log rotation for services on a unit","archived":false,"fork":false,"pushed_at":"2018-12-12T15:31:33.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T02:43:11.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/joedborg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2018-12-11T16:07:45.000Z","updated_at":"2018-12-12T15:31:35.000Z","dependencies_parsed_at":"2023-04-11T19:02:40.748Z","dependency_job_id":null,"html_url":"https://github.com/joedborg/charm-logrotate-reactive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joedborg/charm-logrotate-reactive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate-reactive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate-reactive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate-reactive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate-reactive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joedborg","download_url":"https://codeload.github.com/joedborg/charm-logrotate-reactive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate-reactive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014017,"owners_count":26085346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-09T13:45:36.015Z","updated_at":"2025-10-13T02:43:13.187Z","avatar_url":"https://github.com/joedborg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nThis charm provides a simple way for charms to add log rotation or\nfor an admin to rotate files not otherwise managed.\n\n## Admin-Controlled Usage\nIf you want to rotate un-managed files, this is what you want.\nYou will still need to add a relation to one of your existing services\n(it will use the juju-info interface), as this is a subordinate charm,\nbut logrotate will not interact with that service (just files that happen\nto share the same unit).\n\nThere is a per-logfile config setting:\n\n**logfiles** Provides local logfile settings or overrides package or\ncharmed log rotation.\n\nAs there could be many variations, the logfiles setting is a JSON-format\nstring, set out as follows:\n\n`{\"first_logfile_name\":{\"path\":\"/path/to/logs/*.log\", \"option\":\"value\", ...}}`\n\nWhere *option* can be any of the above settings plus two additional\nones: *prerotate* and *postrotate* which supply pre- and post-rotation commands.\n\nPer-logfile options will override the default settings.\n\nTo manage more than one file, just extend the logfiles string:\n\n`{\"logfile1\": {\u003clocal settings\u003e}, \"logfile2\", {\u003clocal settings\u003e}}`\n\n\n## Charm-Controlled Usage\nIt is also possible for a charm to manage its own log rotation using\nthe logrotate subordinate charm.  A \"logrotate\" interface is provided\nfor this.\n\nUsed like this, you can still have manually-managed log rotation - these\nwill be added to whatever the related charm configures.\n\nPassing the above \"logfiles\" JSON string in the charm's relation\ndata from a logrotate-relation-changed hook should be all that's needed.\n\nFor example:\n\n```\nfrom charmhelpers.core.hookenv import relation_set, relation_id, relation_ids\n\ndef update_logrotate():\n    relation_data = {}\n    relation_data[\"logfiles\"] = '{\"apache2\":{\"path\":\"/var/log/apache2/*.log\",\"when\":\"daily\",\"period\":\"7\"}}'\n    if relation_id():\n        relation_set(None, relation_data)\n    else:\n        for r in relation_ids(\"logrotate\"):\n            relation_set(r, relation_data)\n```\n\n## Notes\nCharm-controlled log-rotation through the logrotate interface can be\noverridden by a matching entry in the *logfiles* config option.  For\nexample, if a charm sets weekly rotation on \"mylogfiles\" using the\nlogrotate relation interface:\n\n`relation_data[\"logfiles\"] = '{\"mylogfiles\":{\"path\":\"/var/log/mycharm/*.log\",\"when\":\"weekly\"}}'`\n\nBut the admin wants them rotated daily, they just need to:\n\n`juju config logrotate logfiles='{\"mylogfiles\":{\"path\":\"/var/log/mycharm/*.log\",\"when\":\"daily\"}}'`\n\n# Example\n```\njuju deploy apache2\njuju deploy logrotate\njuju config logrotate logfiles='{\"apache2\":{\"path\":\"/var/log/apache2/*.log\",\"when\":\"daily\",\"period\":\"28\"}}'\njuju add-relation apache2 logrotate\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoedborg%2Fcharm-logrotate-reactive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoedborg%2Fcharm-logrotate-reactive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoedborg%2Fcharm-logrotate-reactive/lists"}