Skip to content
Create a gist now

Instantly share code, notes, and snippets.

require 'log4r'
require 'log4r/yamlconfigurator'
include Log4r
y = "log4r_config:
# define all loggers ...
- name : production
level : INFO
trace : 'false'
- stdout
# define all outputters (incl. formatters)
- type : StdoutOutputter
name : stdout
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'] 'test'
#=>2010-05-20 14:36:32 INFO: foobar test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.