Custom logger in Rails 3?

前端 未结 2 1750
-上瘾入骨i
-上瘾入骨i 2020-12-30 12:11

I want to have a custom logger for my application, which of course logs to a different file, someone asked a question: Setting up the logger in rails 3

But I want to

2条回答
  •  失恋的感觉
    2020-12-30 12:46

    You could do that with this code

    logfile = File.open('/path/to/log.log', 'a')  
    StatusLogger = Logger.new(logfile)
    StatusLogger.info 'Hello World!'
    

    And you would most likely configure this in an initializer file, or you could do it in an environment file if you wanted.

提交回复
热议问题