Rails production.log file is empty

后端 未结 2 1429
清酒与你
清酒与你 2020-12-17 18:48

I\'m using Rails 2.3.13 and in my environments/production.rb, I have:

config.log_level = :info
RAILS_DEFAULT_LOGGER = SyslogLogger.new(\'mysite-         


        
相关标签:
2条回答
  • 2020-12-17 19:11

    Given how you set the logger, you should find a file named 'mysite-platform-production', not production.log, and it will be on the root directory of your project. If you want to find it in 'log/mysite-platform-production.log' you will have to do:

    RAILS_DEFAULT_LOGGER = SyslogLogger.new('log/mysite-platform-production.log')
    
    0 讨论(0)
  • 2020-12-17 19:14

    You are instantiating a SyslogLogger, so your logging will go into the syslog (in most cases available as a file in /var/log/syslog on Unix systems) and not into a logfile. The parameter you pass to the logger (mysite-platform-production) is the identifier used by syslog and not a filename.

    If you want to log to a file in your log directory, you have to set up your logger as follows:

    RAILS_DEFAULT_LOGGER = Logger.new('log/production.log')
    

    But: I am pretty sure that you don't actually have to do that explicitly but that it is done by default by Rails, so I suggest just not setting RAILS_DEFAULT_LOGGER in your code and you should get a logger that logs into log/production.log implicitly...

    0 讨论(0)
提交回复
热议问题