Rails Custom Logger Format and Production Log Location

The default 2.3.5 Rails logger does not print a Timestamp, or other useful background information. Also, you need to know how to change the log path when deploying in production environments when you don’t want your logs mixed in with your app. Most Unix systems put the logs in /var/log where they can be monitored for size and content and rotated.


The first parameter is the location of the log. If you do not need a customized logger, initiate the standard ActiveSupport::BufferedLogger instead. The second parameter is the severity level: DEBUG, INFO, WARN, ERROR, or FATAL constants as shown above.

config.logger = MyLogger.new( “/var/logsrails.log”, MyLogger::Severity::INFO)

Another problem I had was getting this to work. The config.logger line was not having any effect on my app I started developing on an earlier 2.x release then upgrading to 2.3.5. I managed to get it working by using a fresh config/environment.rb file from a 2.3.5 project.