[英]Separate log file for each tenant
We are building a tenant based web app using acts_as_tenant gem. 我们正在使用act_as_tenant gem构建基于租户的Web应用程序。 Since we are running same app for all the tenants so we have only one log file in whole system. 由于我们为所有租户运行相同的应用程序,因此我们整个系统中只有一个日志文件。 This is causing problem when we need to analyze log of a particular tenant, Currently we are using grep utility to grep on relevant keyword. 当我们需要分析特定租户的日志时,这会引起问题。当前,我们正在使用grep实用程序对相关关键字进行grep。 Obviously this is not an ideal solution. 显然,这不是理想的解决方案。 I am looking for a solution where we can have multiple log files one log file per tenant. 我正在寻找一种解决方案,其中每个租户可以拥有多个日志文件。
This is the point of a tagged logger and rails has one built in : 这就是标记的记录器的重点,并且rails内置了一个 :
Rails.logger.tagged(my_tenant) do
run_some_code
end
This will produce: 这将产生:
[MyTenant] - Updated something in database...
Any good log tool will allow you to easily filter, slice & dice by tag(s). 任何好的日志工具都可以让您轻松地按标签过滤,切片和切块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.