简体   繁体   English

Rails日志级别到文件

[英]Rails log levels to files

I want to log warn messages to a file like warn.log, error messages to a file like error.log. 我想将警告消息记录到类似warn.log的文件中,将错误消息记录到像error.log这样的文件中。 I've googled so many pages and also the StackOverFlow, but I didn't find some parallel topics. 我已经搜索了很多页面以及StackOverFlow,但是没有找到一些并行的主题。 Do you have any good suggestions? 您有什么好的建议吗?

Use this gem multi_level_logger 使用此gem multi_level_logger

Add the following in your config/environments/production.rb 在您的config/environments/production.rb添加以下内容

config.logger =  MultiLevelLogger::MLogger.create(:all=>true)

Now your logs will be written into separate files. 现在,您的日志将被写入单独的文件中。 And your default logger will be disabled. 并且您的默认记录器将被禁用。

For more info check here 欲了解更多信息,请点击这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM