I'm building a web application and have a service layer for business logic. These services are injected into the controllers. Now, I'm wondering what the best practice is in the following situation.
I have a AuthenticatorService
that, unsurprisingly, is responsible for authentication. When a user attempts authenticating, this is clearly something that should be logged. That's something a LoggerService
can handle.
Right now, I'm injecting a LoggerService
into the AuthenticatorService
, but having dependencies between services does not feel very clean...
I'm binding concrete types to interfaces, so logically speaking I would say this is fine - obviously given that it is absolutely certain that the injected service will never have a reason to rely on the other, thus creating a circular dependency.
I'm very interested in reading how others are solving this problem - or, whether it is not a problem at all.
Please do not suggest handling logging from the controller - this is just an example, and there's a lot more situations imaginable where one service might want to call another.