Rails logging to two log files

I wanted to have a Rails 4 app output a local log and ship logs to a central logging server and format these files slightly differently. ActiveSupport::Logger.broadcast makes this really easy but I couldn’t find any documentation or examples online, so I thought I would post this.

I already had a log_formatting.rb initializer file so I added the following to it.