{"id":16416943,"url":"https://github.com/windyakin/awesome_fluent_logger","last_synced_at":"2026-05-14T18:05:47.414Z","repository":{"id":42719480,"uuid":"330093579","full_name":"windyakin/awesome_fluent_logger","owner":"windyakin","description":"A RubyGem for forwarding logs to fluentd.","archived":false,"fork":false,"pushed_at":"2023-03-21T04:43:25.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-20T09:42:04.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/awesome_fluent_logger","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/windyakin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-01-16T05:43:20.000Z","updated_at":"2022-03-27T11:41:03.000Z","dependencies_parsed_at":"2024-01-18T23:04:31.499Z","dependency_job_id":"37e0f3a5-47c2-4950-9de2-68573f1e9c6b","html_url":"https://github.com/windyakin/awesome_fluent_logger","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.4,"last_synced_commit":"013ddd53e848b331626f2f8398e3864add9387b6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windyakin%2Fawesome_fluent_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windyakin%2Fawesome_fluent_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windyakin%2Fawesome_fluent_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windyakin%2Fawesome_fluent_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windyakin","download_url":"https://codeload.github.com/windyakin/awesome_fluent_logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240466791,"owners_count":19805862,"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-11T07:10:34.807Z","updated_at":"2026-05-14T18:05:42.363Z","avatar_url":"https://github.com/windyakin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AwesomeFluentLogger\n\n[![Gem Version](https://img.shields.io/gem/v/awesome_fluent_logger.svg?color=orange\u0026logo=rubygems)](https://rubygems.org/gems/awesome_fluent_logger)\n![ci](https://github.com/windyakin/awesome_fluent_logger/workflows/ci/badge.svg)\n\nThis library can mimic Ruby's built-in Logger class to forward logs to Fluentd. You can use this library not only for Rails but also for pure-Ruby apps.\n\nCommentary: [シンプルに Fluentd にログ転送ができる RubyGem \"awesome_fluent_logger\" をつくった](https://windyakin.hateblo.jp/entry/2021/01/24/143242) (日本語/Japanese)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'awesome_fluent_logger'\n```\n\nAnd then execute:\n\n```\n$ bundle install\n```\n\nOr install it yourself as:\n\n```\n$ gem install awesome_fluent_logger\n```\n\n## Usage\n\n### Tiny example\n\nYour Ruby program:\n\n```ruby\nrequire 'awesome_fluent_logger'\n\nlogger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 })\nlogger.info('information logging')\n```\n\nFluentd output:\n\n```\n2021-01-23 13:28:46.000000000 +0000 info: {\"severity\":\"INFO\",\"time\":\"2021-01-23 13:28:46.336397 +0000\",\"progname\":null,\"message\":\"information logging\"}\n```\n\n### Rails example\n\nRails configure file (`config/application.rb` or `config/environments/{RAILS_ENV}.rb`):\n\n```ruby\nlogger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 })\nconfig.logger = ActiveSupport::TaggedLogging.new(logger)\n```\n\n### Can be set fluent-logger instance in initialize parameters\n\n`:fluent` of initialize argument can be set an instance of [Fluent::Logger::FluentLogger](https://github.com/fluent/fluent-logger-ruby) class.\n\n```ruby\nfluent = Fluent::Logger::FluentLogger.new(nil, socket_path: '/tmp/fluent.sock')\nlogger = AwesomeFluentLogger.new(fluent: fluent)\n```\n\n### Fluent tags\n\nIf the initialize parameter `[:fluent][:tag_prefix]` is specified, it will be inserted at the beginning of the Fluentd tag.\n\n```ruby\nlogger = AwesomeFluentLogger.new(fluent: { tag_prefix: 'kanan', host: 'localhost', port: 24224 })\nlogger.info('ご機嫌いかがかなん？')\n```\n\n```\n2021-01-23 13:28:46.000000000 +0000 kanan.info: {\"severity\":\"INFO\", ...\n```\n\nThe same effect is given by specifying `progname`.\n\n```ruby\nlogger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 }, progname: 'chika')\nlogger.info('かんかんみかん')\n```\n\n```\n2021-01-23 13:28:46.000000000 +0000 chika.info: {\"severity\":\"INFO\", ...\n```\n\nIf both are specified, they will be nested. In this case, tag_prefix will be added first.\n\n```ruby\nlogger = AwesomeFluentLogger.new(fluent: { tag_prefix: 'kanan', host: 'localhost', port: 24224 }, progname: 'chika')\nlogger.info('2人は幼馴染です')\n```\n\n```\n2021-01-23 13:28:46.000000000 +0000 kanan.chika.info: {\"severity\":\"INFO\", ...\n```\n\n### Initialize parameters\n\nOther initialization parameters are based on the Logger class of the Ruby standard library.\n\n| Key | Default | Descriptions |\n|:---|:---|:---|\n| `fluent` | (none) | `Fluent::Logger::FluentLogger` initialize paramater hash or `Fluent::Logger::FluentLogger` class instance |\n| `level` | `Logger::DEBUG` | [Logger severity level constant](https://docs.ruby-lang.org/en/master/Logger.html) |\n| `progname` | `nil` | Program name to include in log messages **and Fluentd tag** |\n| `formatter` | [`AwesomeFluentLogger::Formatter`](lib/awesome_fluent_logger/formatter.rb) | Inherited `Logger::Formatter` class instance |\n| `datetime_format` | `%Y-%m-%d %H:%M:%S.%6N %z` | `%iso8601` or [`Time#strftime` formatted text](https://docs.ruby-lang.org/en/master/Time.html#method-i-strftime) |\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/awesome_fluent_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/awesome_fluent_logger/blob/master/CODE_OF_CONDUCT.md).\n\n\n## License\n\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindyakin%2Fawesome_fluent_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindyakin%2Fawesome_fluent_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindyakin%2Fawesome_fluent_logger/lists"}