How to log something in Rails in an independent log file?

前端 未结 9 1303
栀梦
栀梦 2020-11-30 17:12

In rails I want to log some information in a different log file and not the standard development.log or production.log. I want to do this logging from a model class.

9条回答
  •  忘掉有多难
    2020-11-30 17:46

    I would suggest using Log4r gem for custom logging. Quoting description from its page:

    Log4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations per log event, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more.

提交回复
热议问题