简体   繁体   中英

Separate log file for each tenant

We are building a tenant based web app using acts_as_tenant gem. 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. 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
  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.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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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