Created
December 7, 2009 16:13
-
-
Save mscottford/250898 to your computer and use it in GitHub Desktop.
Helper class for using log4net with IronRuby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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