# BufferedLogger + formatting

**URL:** <https://www.ruby-forum.com/t/bufferedlogger-formatting/125678>\
**Category:** Rails\
**Created:** [January 11, 2008, 3:48am UTC](https://www.ruby-forum.com/t/bufferedlogger-formatting/125678 "2008-01-11T03:48:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nootch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eada6e/32.png) [@nootch](https://www.ruby-forum.com/u/nootch)\
**Post date:** [January 11, 2008, 3:48am UTC](https://www.ruby-forum.com/t/bufferedlogger-formatting/125678/1 "2008-01-11T03:48:10Z")

</div>

I understand that rails 2.x introduced the buffered logger for  
performance and this is great. It also removed, as far as I can tell,  
the formatting that was available in the previous logger. Has anyone  
endeavored to include a formatter with the new logger? Or have any  
recommendations.

Many thanks.

---

<div class="post-metadata">

**Author:** ![nootch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eada6e/32.png) [@nootch](https://www.ruby-forum.com/u/nootch)\
**Post date:** [January 11, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/bufferedlogger-formatting/125678/2 "2008-01-11T23:03:31Z")

</div>

Bumping this …

Was it not included for performance reasons or just not included yet?  
DHH makes reference to removing it in the changeset but doesn’t say  
why:

[http://dev.rubyonrails.org/changeset/7626](http://dev.rubyonrails.org/changeset/7626)

---

<div class="post-metadata">

**Author:** ![nootch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eada6e/32.png) [@nootch](https://www.ruby-forum.com/u/nootch)\
**Post date:** [January 13, 2008, 6:12am UTC](https://www.ruby-forum.com/t/bufferedlogger-formatting/125678/3 "2008-01-13T06:12:13Z")

</div>

Guess I can’t say I’m surprised there’s not a lot of interest in the  
exciting topic of logging.

I ended up creating a super class “FormattedBufferedLogger” and  
initializing it in each of the environment files. The  
FormattedBufferedLogger (which rolls off the tongue I know), overrides  
#add to do some formatting magic and then calls #super

Note that config.logger didn’t work at all. I had to redefine the  
RAILS\_DEFAULT\_LOGGER constant. Like so:

RAILS\_DEFAULT\_LOGGER =  
ExcitingModule::FormattedBufferedLogger.new(File.join(RAILS\_ROOT,  
“log”, “#{RAILS\_ENV}.log”),  
ActiveSupport::BufferedLogger::Severity::DEBUG)
