Sha256: fcb9f63789e14dfb4a727a40f8159947efcaa892586c15e7275e90c6261b1121

Contents?: true

Size: 914 Bytes

Versions: 62

Compression:

Stored size: 914 Bytes

Contents

# Log4r can be configured using YAML. This example uses log4r_yaml.yaml

$: << File.join('..','lib') # path if log4r is not installed
require 'log4r'
require 'log4r/yamlconfigurator'
# we use various outputters, so require them, otherwise config chokes
require 'log4r/outputter/datefileoutputter'
require 'log4r/outputter/emailoutputter'
include Log4r

cfg = YamlConfigurator # shorthand
cfg['HOME'] = '.'      # the only parameter in the YAML, our HOME directory

# load the YAML file with this
cfg.load_yaml_file('log4r_yaml.yaml')

# Method to log each of the custom levels
def do_logging(log)
  log.deb "This is DEB"
  log.inf "This is INF"
  log.prt "This is PRT"
  log.wrn "This is WRN"
  log.err "This is ERR"
  log.fat "This is FAT"
end

# turn off the email outputter
Outputter['email'].level = OFF
# the other two outputters log to stderr and a timestamped file in ./logs
do_logging( Logger['mylogger'])

Version data entries

62 entries across 32 versions & 2 rubygems

Version Path
depengine-0.0.21 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.21 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.20 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.19 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.18 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.17 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.14 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.13 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/log4r-1.1.8/examples/yaml.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/log4r-1.1.8/examples/yaml.rb