Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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