How to customize logger messages in rails 2.3.5

Hi
I would like to know how I can customize logger message format in
rails 2.3.5

Thanks in advance
Tom

On 22 March 2010 11:40, Tom M. [email protected] wrote:

Hi
I would like to know how I can customize logger message format in
rails 2.3.5

I am not sure exactly what you are asking, but the rails guide on
Testing at http://guides.rubyonrails.org/ has some information on how
to use the logger.

Colin

You can overload call method from Formatter.

example:

class Logger
class Formatter
Format = “%s [%s] %s %sn”
def call(severity, time, progname, msg)
Format % [severity, format_datetime(time), progname, msg]
end
end
end

$LOG.error(‘This is much shorter.’)

ERROR [2006-03-31T19:35:01.058646 ] This is much shorter.

2010/3/22 Tom M. [email protected]:

Hi

You can overload call method from Formatter.

example:

class Logger
class Formatter
Format = “%s [%s] %s %sn”
def call(severity, time, progname, msg)
Format % [severity, format_datetime(time), progname, msg]
end
end
end

$LOG.error(‘This is much shorter.’)

ERROR [2006-03-31T19:35:01.058646 ] This is much shorter.

   Thanks for your reply. Where should I place this code? In 

environment.rb or any initializer?

Thanks
Tom

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs