Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bleacherreport/ecto_logger_json
Log ecto data as JSON with slightly different fields
https://github.com/bleacherreport/ecto_logger_json
ecto elixir json logger logging
Last synced: 26 days ago
JSON representation
Log ecto data as JSON with slightly different fields
- Host: GitHub
- URL: https://github.com/bleacherreport/ecto_logger_json
- Owner: bleacherreport
- License: apache-2.0
- Created: 2016-09-21T18:42:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T14:16:39.000Z (over 6 years ago)
- Last Synced: 2024-11-29T12:56:34.942Z (about 1 month ago)
- Topics: ecto, elixir, json, logger, logging
- Language: Elixir
- Homepage:
- Size: 14.6 KB
- Stars: 6
- Watchers: 33
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# EctoLoggerJson
[![Hex pm](http://img.shields.io/hexpm/v/ecto_logger_json.svg?style=flat)](https://hex.pm/packages/ecto_logger_json)
[![Build Status](https://travis-ci.org/bleacherreport/ecto_logger_json.svg?branch=master)](https://travis-ci.org/bleacherreport/ecto_logger_json)
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://github.com/bleacherreport/plug_logger_json/blob/master/LICENSE)Log ecto data as JSON with slightly different fields
## Dependencies
* Poison
* Ecto## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add `ecto_logger_json` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:ecto_logger_json, "~> 0.1.0"}]
end
```2. Ensure `ecto_logger_json` is started before your application:
```elixir
def application do
[applications: [:ecto_logger_json]]
end
```3. Configure ecto logging in `config/enviroment_name.exs`
```elixir
config :my_app, MyApp.Repo,
adapter: Ecto.Adapters.Postgres,
...
loggers: [{Ecto.LoggerJSON, :log, [:info]}]
```### Additonal Setup depending on your use case
*My recommendation would be to only log to a file and not console
otherwise stdout when you are in iex gets very noisy from all the db logs.** Configure the logger (console)
* Add to your `config/config.exs` or `config/env_name.exs`:config :logger, :console,
format: "$message\n",
level: :info,
metadata: [:request_id]* Configure the logger (file)
* Add `{:logger_file_backend, "~> 0.0.7"}` to your mix.exs
* Run `mix deps.get`
* Add to your `config/config.exs` or `config/env_name.exs`:config :logger, format: "$message\n", backends: [{LoggerFileBackend, :log_file}, :console]
config :logger, :log_file,
format: "$message\n",
level: :info,
metadata: [:request_id],
path: "log/my_pipeline.log"## Contributing
Before submitting your pull request, please run:
* `mix credo --strict`
* `mix coveralls`
* `mix dialyzer`Please squash your pull request's commits into a single commit with a message and
detailed description explaining the commit.