{"id":19212065,"url":"https://github.com/joedborg/charm-logrotate","last_synced_at":"2025-02-23T08:13:15.461Z","repository":{"id":145094984,"uuid":"161348246","full_name":"joedborg/charm-logrotate","owner":"joedborg","description":"Configures log rotation for services on a unit","archived":false,"fork":false,"pushed_at":"2018-12-11T14:44:27.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-04T17:23:56.022Z","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":"other","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":null,"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-11T14:43:12.000Z","updated_at":"2018-12-11T14:44:29.000Z","dependencies_parsed_at":"2023-04-11T19:02:35.429Z","dependency_job_id":null,"html_url":"https://github.com/joedborg/charm-logrotate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joedborg%2Fcharm-logrotate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joedborg","download_url":"https://codeload.github.com/joedborg/charm-logrotate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240286518,"owners_count":19777353,"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","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.198Z","updated_at":"2025-02-23T08:13:15.436Z","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# Configuration\n\nThere are several settings that configure defaults:\n\n* **when** When the logs should be rotated (daily, weekly, etc.)\n* **period** How many logs we should keep before they get deleted\n* **perms** Logfile permissions (as chmod)\n* **owner** Logfile owner\n* **group** Logfile group\n* **dateext** Use dateext? (true or false)\n* **compress** Compress the logs or not (compress or nocompress)\n* **compresscmd** What command to compress with (gzip, bzip2 or xz)\n* **compressext** What file extension to use for compressed files (determined\nautomatically if not set)\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 set logrotate logfiles='{\"mylogfiles\":{\"path\":\"/var/log/mycharm/*.log\",\"when\":\"daily\"}}'`\n\n# Example\n```\njuju add-unit apache2\njuju add-unit logrotate\njuju set logrotate logfiles='{\"apache2\":{\"path\":\"/var/log/apache2/*.log\",\"when\":\"daily\",\"period\":\"28\"}}'\njuju add-relation apache2 logrotate\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoedborg%2Fcharm-logrotate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoedborg%2Fcharm-logrotate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoedborg%2Fcharm-logrotate/lists"}