class Log4r::Configurator

See log4r/configurator.rb

Constants

ExcludeParams

Public Class Methods

[](param) click to toggle source

Get a parameter’s value

# File lib/log4r/configurator.rb, line 25
def self.[](param); @@params[param] end
[]=(param, value) click to toggle source

Define a parameter with a value

# File lib/log4r/configurator.rb, line 27
def self.[]=(param, value); @@params[param] = value end
custom_levels(*levels) click to toggle source

Sets the custom levels. This method accepts symbols or strings.

Configurator.custom_levels('My', 'Custom', :Levels)

Alternatively, you can specify custom levels in XML:

<log4r_config>
  <pre_config>
    <custom_levels>
      My, Custom, Levels
    </custom_levels>
    ...
# File lib/log4r/configurator.rb, line 42
def self.custom_levels(*levels)
  return Logger.root if levels.size == 0
  for i in 0...levels.size
    name = levels[i].to_s
    if name =~ %r\s/ or name !~ %r^[A-Z]/
      raise TypeError, "#{name} is not a valid Ruby Constant name", caller
    end
  end
  Log4r.define_levels *levels
end
load_xml_file(filename) click to toggle source

Given a filename, loads the XML configuration for Log4r.

# File lib/log4r/configurator.rb, line 54
def self.load_xml_file(filename)
  detect_rexml
  actual_load Document.new(File.new(filename))
end
load_xml_string(string) click to toggle source

You can load a String XML configuration instead of a file.

# File lib/log4r/configurator.rb, line 60
def self.load_xml_string(string)
  detect_rexml
  actual_load Document.new(string)
end