'Universal interface for all logging libraries?

Is it possible or even make a sense to create some universal interface for all or much of the logging libraries (NLog, log4net, and so on)? The task is pretty common - to create a possibility to change the logging framework almost on the fly, without digging into the whole application and searching all the callings to the specific logging framework. I use C# and .NET, but advices from another languages would be welcome also.

Various libraries have various sets of log levels, formatters, and so on. So to cover all of them I have to implement my own set of levels, formatters and all the conceptions about logging. This is a ton of work, and and can include tens of levels that I actually don't need for logging, but for compatibility between many logging frameworks.

Another approach is to make the less functionality as possible. Something like a single Log method with a various parameters to cover all the cases. Or a small amount of methods for the main cases like LogInfo, LogError, LogDebug, and LogAllTheRest. I can also log only a single message without formatters, but include all the formatting work inside this message. But in this case I have to limit the formatting functionality to the capabilities, available to String type. It will be less configurable and suitable in comparison to formatters of logging libraries.

Checked this thing ILogger Interface, but as for me, it tries to cover all the cases, as I described before, but anyway has lack of variants and possibilities. For example, no Fatal level of logging, as it is in log4net. So even with this interface I should find some lowest common denominator of possibilities and limit myself.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source