Search code examples
javaloggingencapsulationslf4japache-commons-logging

Is it worth wrapping a logging framework in an additional layer?


I'm currently looking at upgrading the logging mechanism in a medium-to-large-sized Java codebase. Messages are currently logged using static methods on a Debug class, and I have recommended switching from this to something like SLF4J or commons-logging.

The application architect prefers that I encapsulate the dependency on SLF4J (possibly by wrapping it up in the aforementioned Debug class). This will make it easier to change the logging implementation in the future.

This seems like overkill to me, as SLF4J is already abstracting the concrete logging implementation.

Is it worth wrapping a 3rd-party logging abstraction like SLF4J in another home-grown abstraction?


Solution

  • I entirely agree with you: wrappers of wrappers of wrappers are getting out of hand. I suspect that architect doesn't realize how SLF4J in particular can easily wrap any other logging system, so that "changing implementation" is perfectly feasible without yet another layer of wrappage.