Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Kimmax Don't believe it is, personally. `@Log4j` or whatever on the class to provide the logger is just simpler, easier, has less boilerplate and works fine. If you needed to mock it or switch out loggers at runtime then I'd agree - but that's rarely the case, and if you're testing log output that's... kinda weird, and points to other issues.
-
What if I don't want my tests project to have a dependency on whatever log framework we use?
And it should be pretty easy to mock a logger. The mock framework I use does it for free -
@M3m35terJ05h The tests project would have to have a dependency on the logger if it's just annotated rather than passed in via DI surely?
-
@AlmondSauce Yeah that's what I'm saying. I don't want that therefore I don't want annotations therefore I want di
-
@M3m35terJ05h Sorry, wrong way around, still waking up.
If it's just annotated on the non-test class, why would that create a test dependency? -
@AlmondSauce hmmm yeah actually I guess it wouldn't since the tests just depend on the already compiled main project so the tests don't need to know what to do with the annotation. Carry on.
Dude, stop using dependency injection for your loggers. We don't need to inject that crap. Just define it and be done.
rant