Using log4net with IronRuby is something of a pain. This is for two reasons.
- log4net violates Microsoft’s API naming guidelines by naming the root namespace in the log4net assembly as ‘log4net’. A conforming name would look more like ‘Log4Net’.
- IronRuby ignores any namespaces that start with lowercase letter. It will flat out refuse to load them.
These two facts together lead to total suck, but I have found a work around. I wrote a wrapper class that invokes the log4net assembly via reflection. This lets you call log4net.Config.BasicConfigurator.Configure()
so that log4net gets configured from the app.config
file. The wrapper class also allows you to access named loggers and provides a way to output the log levels that are configured for the root logger.
Enjoy!
Tags: corgibytes