Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created December 7, 2009 16:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mscottford/250898 to your computer and use it in GitHub Desktop.
Helper class for using log4net with IronRuby.
class Log4Net
def initialize()
@log4net = IronRuby.require('log4net')
end
def configure
@log4net.GetType("log4net.Config.BasicConfigurator").GetMethod("Configure", System::Array.of(System::Type).new(0)).Invoke(nil, nil)
end
def logger(log_name)
log = @log4net.GetType("log4net.LogManager").GetMethod("GetLogger", System::Array.of(System::Type).new(1) {System::String.to_clr_type}).Invoke(nil, System::Array.of(System::String).new(1) {log_name})
end
def print_root_log_levels
log = logger('default')
puts "Is debug enabled: #{log.IsInfoEnabled}"
puts "Is error enabled: #{log.IsErrorEnabled}"
puts "Is fatal enabled: #{log.IsFatalEnabled}"
puts "Is info enabled: #{log.IsInfoEnabled}"
puts "Is warn enabled: #{log.IsWarnEnabled}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment