Custom levels are process-wide and you cannot reset it after it's already set. But there might be some way to achieve what you want.
Problem 1
Previous custom levels must be set for a reason, and logger methods and outputter methods are created during setting up the custom levels, thus you should be careful if you're going to remove some of the custom levels which might cause unexpected errors.
However, there is a workaround to reset the custom levels from my fork of Log4r and it's for test purpose. (This method resets log4r to the original state, wipes out all existing loggers and outputters)
Problem 2
There are two solutions to resolve the conflicts:
- Define all custom levels before other modules do. And you must include all custom levels. e.g.
['Foo', 'Bar', 'Bing', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL']
- If you cannot do that before other modules do, use the method above to reset log4r and redefine custom levels and also load configurations from other modules if needed
- Use alias methods as follow and change your log4r configuration correspondingly (e.g. replace foo with debug, etc.)
Log4r::Logger.module_eval %{
alias_method :foo, :debug
alias_method :bar, :info
alias_method :baz, :error
alias_method :qux, :fatal
}
Hope it helps.