Custom Logging Best Practices in Ruby

2019-05-10 06:43发布

What are best practices for managing custom logging in Ruby? Should I be monkeypatching logger to do what I want? Or extending from it? Or delegating? What's the rubyish way? I'm sick of custom hacks for this; I'd like something cleaner, and ideally more elegant.

3条回答
虎瘦雄心在
2楼-- · 2019-05-10 07:33

According to my experience, log4r is no more popular (and I don't know why these days I can't access log4r's homepage). Instead logging is far more better.

FYR

https://www.ruby-toolbox.com/categories/logging

查看更多
啃猪蹄的小仙女
3楼-- · 2019-05-10 07:34

Bates has a screencast on customizing logger.

And here is a blog post on custom logging in Rails.

Here are some tips on logging in Rails.

查看更多
狗以群分
4楼-- · 2019-05-10 07:43

There's a Ruby implementation of Slf4j, the popular Java logging framework, imaginatively called Slf4r. This separates the actual logging method from the code, and provides a standard interface for logging different message levels.

查看更多
登录 后发表回答