Last Modified
Fri Sep 18 22:16:43 -0700 2009
  • singleton
  • log4r/base



Formatters are responsible for formatting LogEvent data. An Outputter owning a Formatter will invoke the Log4r::Formatter#format method prior to writing.

Available Formatters

XML Configuration

Specify the Formatter and its class (as type) under an <outputter> directive:

  <outputter name="someout" type="sometype">
    <formatter type="Log4r::BasicFormatter"/>

As explained in log4r/configurator.rb, the hash arguments you would normally pass to new are specified as XML parameters. Only PatternFormatter has any of these.

Custom Formatting

Building a custom Formatter is extremely easy. Just define a class that extends Formatter and override the Formatter#format method. Then give it to any interested Outputters.

If you’re interested in setting up your custom formatters in XML, please take a look at log4r/configurator.rb.

Data Available

See Log4r::LogEvent

Version:$Id: formatter.rb,v 1.2 2009/09/19 05:16:43 colbygk Exp $