简体   繁体   English

关闭生产中的活动记录日志

[英]Turn off active record logging in production

How can I turn off the verbose active record logging in production? 如何关闭生产中的详细活动记录日志? (Like every SQL statement is logged) My logs are filling up really fast because I have background jobs running loads of queries. (就像记录每个SQL语句一样)我的日志很快就装满了,因为我有后台作业在运行查询负载。 This is fine on my development server but I don't need this logged in production. 这在我的开发服务器上很好,但是我不需要在生产环境中登录。

To turn off completely, just add this to your environment file (ie production.rb ): 要完全关闭,只需将其添加到您的环境文件(即production.rb )中:

config.active_record.logger = nil

See AR guide (section 3.6): 参见AR指南 (第3.6节):

config.active_record.logger accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then passed on to any new database connections made. config.active_record.logger接受符合Log4r接口或默认Ruby Logger类的记录器,然后将其传递到建立的任何新数据库连接。 You can retrieve this logger by calling logger on either an Active Record model class or an Active Record model instance. 您可以通过在Active Record模型类或Active Record模型实例上调用logger来检索此logger。 Set to nil to disable logging. 设置为nil以禁用日志记录。

There's more options (like selectively turning on / off) documented in other posts. 其他帖子中记录了更多选项(例如有选择地打开/关闭)。 See Disable Rails SQL logging in console as a starting point. 请参阅在控制台中禁用Rails SQL登录作为起点。

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

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