public

  • Download Gist
log4r yaml configurator example.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
require 'log4r'
require 'log4r/yamlconfigurator'
 
include Log4r
 
y = "log4r_config:
 
# define all loggers ...
loggers:
- name : production
level : INFO
trace : 'false'
outputters:
- stdout
 
# define all outputters (incl. formatters)
outputters:
- type : StdoutOutputter
name : stdout
formatter:
date_pattern: '%Y-%m-%d %H:%M:%S'
pattern : '%d %l: #\{TEST\} %m '
type : PatternFormatter"
 
h = YAML.load y
log_cfg = YamlConfigurator
log_cfg['TEST'] = 'foobar'
log_cfg.decode_yaml h['log4r_config']
@log = Logger['production']
@log.info 'test'
#=>2010-05-20 14:36:32 INFO: foobar test

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.