Created
May 30, 2010 20:58
-
-
Save textarcana/419328 to your computer and use it in GitHub Desktop.
log4r yaml configurator, see http://stackoverflow.com/questions/2856205/log4r-logger-inheritance-yaml-configuration-alternatives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment