I have a bunch of logging statements when important database changes are made. For example,
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
logger.info "INFO -- #{Time.now} -- User #{@user.first_name} #{@user.last_name} (ID: #{@user.id}) updated their profile"
flash[:success] = "Profile updated"
redirect_to @user
else
render 'edit'
end
end
I can get these by searching through the output of heroku logs
, but it seems that heroku only keeps about 1000 lines of logging so my statements get pushed out. Is there a way to save these to a file and keep only the "INFO" statements up to a certain number of lines (something like 10000)?
Alternatively, would it be possible to "turn off" output like
2016-04-20T10:28:52.031573+00:00 app[web.1]: Role Load (0.8ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 AND (((roles.name = 'scout') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["user_id", 135]]
2016-04-20T10:28:52.046090+00:00 app[web.1]: Role Load (0.8ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 AND (((roles.name = 'scout') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["user_id", 143]]
2016-04-20T10:28:52.056567+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.1ms)
2016-04-20T10:28:52.060492+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.2ms)
2016-04-20T10:28:52.060925+00:00 app[web.1]: Completed 200 OK in 215ms (Views: 167.9ms | ActiveRecord: 41.7ms)
2016-04-20T10:28:52.048956+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" INNER JOIN "relationships" ON "users"."id" = "relationships"."followed_id" WHERE "relationships"."follower_id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["follower_id", 143]]
2016-04-20T10:28:52.057903+00:00 app[web.1]: CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["user_id", 165]]
2016-04-20T10:28:52.050240+00:00 app[web.1]: CACHE (0.0ms) SELECT "users".* FROM "users" INNER JOIN "relationships" ON "users"."id" = "relationships"."followed_id" WHERE "relationships"."follower_id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["follower_id", 143]]
2016-04-20T10:28:52.058796+00:00 app[web.1]: CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 AND (((roles.name = 'der') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["user_id", 165]]
?