# Simple Logging Customization

**URL:** <https://www.ruby-forum.com/t/simple-logging-customization/134769>\
**Category:** Rails\
**Created:** [April 14, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/simple-logging-customization/134769 "2008-04-14T23:10:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 14, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/simple-logging-customization/134769/1 "2008-04-14T23:10:30Z")

</div>

Is there a simple way to customize logging so that when you call the  
logger method it includes the severity in the log? I just want to  
make it easy to find with something like a GREP.

So a call to this:  
logger.warn(‘my message’)

Would put this in the log:  
WARNING: My message

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 15, 2008, 5:40am UTC](https://www.ruby-forum.com/t/simple-logging-customization/134769/2 "2008-04-15T05:40:35Z")

</div>

On Mon, Apr 14, 2008 at 5:09 PM, TomRossi7 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a simple way to customize logging so that when you call the  
> logger method it includes the severity in the log? I just want to  
> make it easy to find with something like a GREP.
> 
> So a call to this:  
> logger.warn(‘my message’)
> 
> Would put this in the log:  
> WARNING: My message

[http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging](http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging)

Just create a custom formatter and reference the log level there.  
Something like the following, warning this has not been tested.

class Logger  
def format\_message(severity, timestamp, progname, msg)  
“#{RAILS\_DEFAULT\_LOGGER.level} #{timestamp} (#{$$}) #{msg}\n”  
end  
end

Regards,  
Michael G.
