Adam Lee
Adam Lee

Reputation: 25748

is there a way to use logger in application.rb?

For Rails4 application, is there a way to use logger in the application.rb?

I need to print out some log information here before anything else.

Upvotes: 1

Views: 536

Answers (1)

Mareq
Mareq

Reputation: 1351

Yes, it is possible:

logger = ActiveSupport::TaggedLogging.new(Logger.new(File.join(Rails.root, "log/configuration.log")))
logger.info("Some log entry")

If you want to redirect all log output to the console you may try:

logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
logger.info("Some log entry to the console")

or for simply inspection of something:

puts "Another log entry to the console"

Upvotes: 1

Related Questions