Sha256: 68c38f2393eb0aed2f47752e9fde04059edc8233c5bd06e76d43a1e680addc5f

Contents?: true

Size: 1.1 KB

Versions: 64

Compression:

Stored size: 1.1 KB

Contents

$: << File.join("..", "lib")

require 'log4r'
require 'log4r/staticlogger'
require 'log4r/formatter/log4jxmlformatter'
require 'log4r/outputter/udpoutputter'
require 'log4r/outputter/consoleoutputters'

include Log4r

log4r = Logger.new 'log4r'
log4r.trace = true
log4r.outputters = StdoutOutputter.new 'log4r'
log4r.level = ALL

formatter = Log4jXmlFormatter.new
outputter = UDPOutputter.new 'udp', :hostname => "localhost", :port => 8071
outputter.formatter = formatter

mylog = Logger.new 'mylog'
mylog.trace = true
mylog.outputters = [outputter]

# Log4r::Formatter throws when formatting
# an excpetion with a nil backtrace (line 73).
def get_exception(msg)
  begin
    raise msg
  rescue Exception => e
    e
  end
end

NDC.push "saw test"

MDC.put "clientip", %q{10.33.33.33}

def do_log(log)
    log.debug "This is a message with level DEBUG"
    log.info "This is a message with level INFO"
    log.warn "This is a message with level WARN"
    log.error "This is a message with level ERROR"
    log.fatal "This is a message with level FATAL"

    log.fatal get_exception( "This is an exception" )
end

do_log(mylog)

Version data entries

64 entries across 34 versions & 4 rubygems

Version Path
depengine-0.0.31 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.31 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.23 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb
depengine-0.0.22 etc/isolate/jruby-1.8/gems/log4r-1.1.8/tests/testchainsaw.rb