{"id":16963458,"url":"https://github.com/lzap/logging-journald","last_synced_at":"2026-05-01T03:37:12.428Z","repository":{"id":56881898,"uuid":"117982211","full_name":"lzap/logging-journald","owner":"lzap","description":"Logging gem plugin for system journal","archived":false,"fork":false,"pushed_at":"2022-09-30T11:08:50.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T01:05:08.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lzap.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}},"created_at":"2018-01-18T12:50:47.000Z","updated_at":"2022-09-30T09:50:17.000Z","dependencies_parsed_at":"2022-08-20T23:40:50.877Z","dependency_job_id":null,"html_url":"https://github.com/lzap/logging-journald","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzap%2Flogging-journald","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzap%2Flogging-journald/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzap%2Flogging-journald/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzap%2Flogging-journald/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzap","download_url":"https://codeload.github.com/lzap/logging-journald/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244827644,"owners_count":20516969,"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-10-13T23:24:55.931Z","updated_at":"2026-05-01T03:37:07.381Z","avatar_url":"https://github.com/lzap.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Logging Journald\nby Lukas Zapletal [![](https://secure.travis-ci.org/lzap/logging-journald.svg)](https://travis-ci.org/lzap/logging-journald)\n\n* [Homepage](http://rubygems.org/gems/logging-journald)\n* [Github Project](https://github.com/lzap/logging-journald)\n\n### Description\n\n**Logging Journald** is a plugin for [logging gem](https://github.com/TwP/logging) - the flexible logging library for use in Ruby programs. It supports logging to system journal via journald-logger and journald-native gems.\n\n### Installation\n\n```\ngem install logging-journald\n```\n\nThe gem provides journald appender and noop layout that does no formatting since core library does not provide such a layout. Apppender options are:\n\n* name - name of the appender (required)\n* ident - optional log ident (appender name by default)\n* layout - optional layout (no formatting by default)\n* mdc - log mdc into custom journal fields (true by default)\n* ndc - log ndc hash values into custom journal fields (true by default)\n* facility - optional syslog facility rendered as SYSLOG_FACILITY (LOG_USER (8) by default)\n* extra - extra custom journal fields as hash\n\nAll custom fields are converted to uppercase by joudnald automatically, for more details [visit official documentation](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html).\n\n### Examples\n\nUse MDC to send arbitrary key/value pairs to system journal:\n\n```ruby\nrequire 'logging'\n\nlog = Logging.logger['app']\nlog.add_appenders(Logging.appenders.journald('myservice'))\n\n# use mapped diagnostic context to send custom fields\nLogging.mdc['signed_user'] = 'Ondra'\nlog.debug \"blah blah\"\n```\n\nThe example above will be rendered as:\n\n```\n# journalctl -o verbose\n  MESSAGE=blah blah\n  SYSLOG_FACILITY=8\n  SIGNED_USER=Ondra\n  PRIORITY=2\n  SYSLOG_IDENTIFIER=myapp\n  _PID=25979\n  _TRANSPORT=journal\n  _UID=1000\n  _GID=1000\n  _MACHINE_ID=xxx\n  _HOSTNAME=xxx\n  _BOOT_ID=xxx\n  ...\n```\n\nMapped diagnostic contexts are great for global values like logged user, request or session id. There are two more options to send arbitrary key/value pairs:\n\n```ruby\nrequire 'logging'\n\nlog = Logging.logger['app']\nlog.add_appenders(Logging.appenders.journald('myservice'))\n\n# nested diagnostic context is a stack of values and\n# it can be used but only hashes are taken into account\nbegin\n  Logging.ndc \u003c\u003c { exception: err, backtrace: err.backtrace }\n  log.fatal \"an exception occured\"\nensure\n  Logging.ndc.clear\nend\n\n# hash can be provided instead of string but in this case\n# layout cannot be used to format message in the system journal\nlog.info message: \"this must be called 'message'\", akey: \"a value\"\n```\n\nThere are some examples in the [examples folder](/examples).\n\n### License\n\nThe MIT License - see the [LICENSE](/LICENSE) file for the full text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzap%2Flogging-journald","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzap%2Flogging-journald","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzap%2Flogging-journald/lists"}