https://github.com/gingray/logging_best_practice_ruby
https://github.com/gingray/logging_best_practice_ruby
best-practice best-practices bestpractices logger logging ruby
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gingray/logging_best_practice_ruby
- Owner: gingray
- Created: 2018-07-26T12:42:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-26T13:02:40.000Z (about 7 years ago)
- Last Synced: 2025-02-26T08:14:58.883Z (7 months ago)
- Topics: best-practice, best-practices, bestpractices, logger, logging, ruby
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Logging best practice in Ruby
It's opionated stuff but it was from my practice.1. Write logs in json format it will help you to easy transform it and process in ElasticSearch or in something similar
2. Add time key into json logs it also can help you to process logs in Kibana and app event can be differ from time when log was save espessially when you use centralized storage for logs
3. Seaparate logs by type it's not about sevrerity but about physical storage like _bussines events_, _logs for yourself_, _tech logs(standard rails log, gem logs)_
4. Add _Trace Id_ (SecureRandom.hash or something else) to log entity it helps you to use tools like [Zipkin](https://github.com/openzipkin/zipkin) to trace issues from distributed system if you have microservices
5. Write logs through you custom singleton class it give you more fine control instead of using standard Rails loggerits opionated you might not agree with that but if so let me know. Its fine to disagree with someone.
Usefull links:
[https://github.com/rocketjob/semantic_logger](https://github.com/rocketjob/semantic_logger) - logger
[https://github.com/vsevolod/xyeger](https://github.com/vsevolod/xyeger) - logger
[https://github.com/roidrage/lograge](https://github.com/roidrage/lograge) - logger