{"id":15493865,"url":"https://github.com/driv3r/logger_backends_json","last_synced_at":"2025-10-14T06:10:52.372Z","repository":{"id":57517764,"uuid":"73476718","full_name":"driv3r/logger_backends_json","owner":"driv3r","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-22T11:46:30.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-23T02:59:42.526Z","etag":null,"topics":["async","elixir","json-logger"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/driv3r.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-11T12:40:21.000Z","updated_at":"2017-02-15T02:04:59.000Z","dependencies_parsed_at":"2022-09-26T18:01:31.581Z","dependency_job_id":null,"html_url":"https://github.com/driv3r/logger_backends_json","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/driv3r/logger_backends_json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driv3r%2Flogger_backends_json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driv3r%2Flogger_backends_json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driv3r%2Flogger_backends_json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driv3r%2Flogger_backends_json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/driv3r","download_url":"https://codeload.github.com/driv3r/logger_backends_json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driv3r%2Flogger_backends_json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018121,"owners_count":26086280,"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-14T02:00:06.444Z","response_time":60,"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":["async","elixir","json-logger"],"created_at":"2024-10-02T08:09:44.441Z","updated_at":"2025-10-14T06:10:52.345Z","avatar_url":"https://github.com/driv3r.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logger Backends JSON [![Build Status](https://travis-ci.org/driv3r/logger_backends_json.svg?branch=master)](https://travis-ci.org/driv3r/logger_backends_json)\n\nYet another (but flexible) JSON backend for Logger. Pick whatever json encoder you want (poison, json, exjsx) or provide your own.\n\n## Roadmap\n\n- [x] Basic functionallity, dumb IO usage, configuration and using given parsing lib.\n- [x] Proper formatting of error messages taken from `error_logger` which come in as lists\n- [ ] Improve documentation on hex docs.\n- [ ] Buffered \u0026 async sending messages to IO `:user` process.\n- [x] Filtering of messages via configured function in addition to log levels.\n- [ ] Adding examples of custom json encoders.\n- [x] Allowing custom message builders.\n- [ ] Additional switchable IO backends, i.e. TCP, UDP, File\n\n## Installation\n\nThe package can be installed as:\n\n  1. Add `logger_backends_json` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [\n        # your json library of choice, otherwise you will need to provide custom module.\n        {:poison, \"~\u003e 3.0\"},\n        {:logger_backends_json, \"~\u003e 0.5.0\"}\n      ]\n    end\n    ```\n\n  2. Update your config\n\n    ```elixir\n    # A tuple with module and config name to use\n    config :logger, backends: [{Logger.Backends.JSON, :json}]\n\n    config :logger, :json,\n      level: :info,\n      metadata: %{foo: \"bar\"},\n      encoder: Poison\n    ```\n\n## Extra configuration\n\nThis library uses [`ConfigExt`](https://github.com/driv3r/config_ext) for loading dynamic configuration, like environment variables or functions on runtime.\n\n```elixir\ndefmodule Foo do\n  def bar(baz), do: %{bar: inspect(baz), env: System.get_env(\"APP_ENV\")}\n\n  alias Logger.Backends.JSON.Event\n\n  def create(%Event{} = event), do: %{text: event.message}\n  def allow?(%Event{} = event), do: event.message != \"ping\"\nend\n\nSystem.put_env \"LOG_LEVEL\", \"debug\"\n\nconfig :logger, :json,\n  level: {:system, \"LOG_LEVEL\", :info},\n  metadata: {:function, Foo, :bar, [:baz]},\n  encoder: Poison,\n  event: Foo\n```\n\nAll possible options:\n\n- `encoder` anything that implements `encode(object) :: map|list =\u003e {:ok, json}`, we test against `poison`, `exjsx` and `json` libs.\n- `level` represents log level, same as in default `Logger` - `debug, info, warn, error`.\n- `metadata` additional info to pass into json, should be `Map` in the end.\n- `event` a module that implements `build(%Event{}) :: map` and `allow?(%Event{}) :: boolean` functions.\n\nIn any case you can also specify a function that will get evaluated on initialization, if you need to update it during runtime - just run `Logger.configure_backend(...)`.\n\nIf you need to pass any extra info on each log, i.e. some stuff from ETS tables or whatever, you can do it by creating custom encoder and adding it there.\n\n## Frequent issues\n\n  1. This backend doesn't install any dependencies - it doesn't come with any default JSON encoder - so when you try to assign `Poison` as encoder, but you didn't installed it you will get a message like\n\n    ```elixir\n    iex(1)\u003e\n    =INFO REPORT==== 16-Nov-2016::09:57:32 ===\n        application: logger\n        exited: shutdown\n        type: temporary\n    ```\n\n    to solve it just install `:poison` (or any other json lib) by following their installation instructions, and everything should be back to good.\n\n## Sources \u0026 inspiration\n\n- [user process](http://ferd.ca/repl-a-bit-more-and-less-than-that.html) Erl shell workings and what is user process.\n- [elixir#4720](https://github.com/elixir-lang/elixir/pull/4720) performance via calling user process directly.\n- [elixir#4728](https://github.com/elixir-lang/elixir/pull/4728) performance via buffering IO and sending stuff async.\n- various json loggers (i.e. `json_logger` and `logger_logstash_backend`)\n\n## License\n\nThis source code is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriv3r%2Flogger_backends_json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdriv3r%2Flogger_backends_json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriv3r%2Flogger_backends_json/lists"}