简体   繁体   English

每个租户的单独日志文件

[英]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. 我正在寻找一种解决方案,其中每个租户可以拥有多个日志文件。

  1. Is this possible to maintain multiple log files in a single Rails application 是否可以在单个Rails应用程序中维护多个日志文件
  2. What would be the drawback of having multiple log files ? 拥有多个日志文件的缺点是什么?

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.

相关问题 有什么办法可以将每个请求分开保存在Rails日志中? - Any way to keep each request separate in the Rails log? 在Rails应用程序中为每个Passenger进程创建单独的日志 - Creating a separate log for each Passenger process in a Rails app 如何将Rails错误记录到单独的日志文件中? - How can I log Rails errors into a separate log file? Rails中每个模型的单独验证文件 - Separate validation file for each model in rails JRuby on Rails应用程序中的log4j - 将日志重定向到单独的文件 - log4j in a JRuby on Rails app - redirecting logs to a separate file 如何将响应字符串作为每个单词的单独行插入文件中? - How to insert response string into file as separate lines with each word? Rails 文件上传 - 扫描文件; 并为每个用户单独的文件夹 - Rails File Upload - Scan files; and separate folders for each user 将单独的日志加入主要的Rails开发日志 - Joining separate log to main Rails development log jQuery-file-upload:如何根据每个文件大小发送单独的请求 - jQuery-file-upload: how to send separate request per each file size 在Rails视图中将“每个”分隔为“类型” - Separate “each” to “types” in Rails view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM