Anand
Anand

Reputation: 10400

Rails3 Custom logger

I created a new logger

my_logger = Logger.new(File.join(Rails.root, 'log', 'my_log.log'))
my_logger.info "my message"

and I tried logging some bit of texts on this log file.

Here is the logger_level of all my environments.

Development = 0 - Logger::DEBUG

Staging = 1 - Logger::INFO

Production = 1 - Logger::INFO

This works perfectly in development and staging environments. But the my_logger.info "my message" does nothing in production environment. It doesn't throw any error also. Can you tell what could have gone wrong in just "production" environment with my new logger?

Upvotes: 2

Views: 3803

Answers (3)

utiq
utiq

Reputation: 1381

Try putting this in application.rb

if defined?(Rails) && (Rails.env == 'development')
  Rails.logger = Logger.new(STDOUT)
end

Upvotes: 0

Duke
Duke

Reputation: 7442

Rails3 custom logging options?

Upvotes: 0

johmas
johmas

Reputation: 689

If you're looking to customize the output of the Rails3 logger, try this gem: https://github.com/johmas/itslog

Upvotes: 2

Related Questions