We are talking about using the Adapter Pattern for logging. I’m not sure that this is a good idea since we will probably never change our logging implementation, but a question arose while we spoke about this : Does the abstract logging module should hide the configuration details of the various logging implementations ?
I have seen two projects using an Adapter Pattern to abstract logging (one of them is the Common Infrastructure Library for .NET).
In both projects, the configuration the client must provid depends on logging implementations. For example, the client must provide a Log4Net config file if log4net is used.
Am I wrong when I think that this is an incomplete implementation of the Adapter Pattern ? To me, if the client must have some knowledge about the adaptee, it will not be possible to swap the implementation without breaking the client…
But I’m not sure.
Thank you for your advice.
It depends.
In general I agree. If a client needs to no something specific of a specifc service implementation in order to use it although the client is using some kind of abstraction, the abstraction is broken.
But in your case I think you mix up two different clients of the logging library.
One client is the application trying to get out information about its state into the world. It should not in any way be concerned with the configuration.
The other client is who or whatever sets up the environment for your application. This client should ONLY be considered with configuration.
So your Adapter is applying only for the first client is complete for this client.