Sha256: c68694c3aa377023b4b06bcc39c8e388690baade5d9e88a5052a506c1fa16825

Contents?: true

Size: 970 Bytes

Versions: 63

Compression:

Stored size: 970 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'
require 'log4r/outputter/scribeoutputter'

cfg = Log4r::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
Log4r::Outputter['email'].level = Log4r::OFF
# the other two outputters log to stderr and a timestamped file in ./logs
do_logging( Log4r::Logger['mylogger'])

Version data entries

63 entries across 55 versions & 14 rubygems

Version Path
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/examples/yaml.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/examples/yaml.rb