Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to troubleshoot broken Rails logger (not accepting log_tags)?

I've moved a Rails 3.2.5 app from Heroku to a VPS and while the app was working beautifully on Heroku in terms of the log drain output, unfortunately all log output on the VPS and even running locally lacks timestamps or any other tags I'd like to prepend.

After attempting to create a fresh test app and including the following one of the config/envrionments or config/application.rb I've found that it prepends the indicated tags:

config.log_tags = [:uuid, :remote_ip, lambda { |req| Time.now }]

Notwithstanding, I've tried everything I can think of so far from combing through the app gems to grepping everything for any occurrence of "log" within the config and lib folders and subfolders (such as initializers).

I don't know, if somehow the Rails logger may be disabled, how can I find this out? Or what else could be going on here? Or what should I look for precisely?... Or should I attempt to force Rails logger and, if so, where & what should I insert Rails logger reset code to find out in an attempt to isolate where during system init the problem is occurring?

like image 939
ylluminate Avatar asked Aug 03 '12 00:08

ylluminate


People also ask

How Rails logger works?

Rails makes use of the ActiveSupport::Logger class to write log information. Other loggers, such as Log4r , may also be substituted. By default, each log is created under Rails. root/log/ and the log file is named after the environment in which the application is running.

Where does Rails logger write to?

In a Rails app, logs are stored under the /log folder. In development mode, the development. log file is used & you see log output on the terminal you're running rails server on.


1 Answers

I had the same issue, you probably need to use ActiveSupport::TaggedLogging.

  config.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
like image 91
anveo Avatar answered Oct 27 '22 09:10

anveo