Why don't you instantiate a custom logger that you would inject as a dependency? #36
-
Hello, Thanks for those articles and for that demo project. It helps a lot to study application design! I was often being told that loggers are explicit dependencies like any other and that it was a good idea to inject them the same way as a DB or any other application dependency. I know it is not a general rule, and that it always depends on context but I wanted to know why you decided to use the global logger of the I also have another kind of related question about the setup and teardown of your HTTP servers. Here is the piece of code I will refer to (extract from
Why use And the last question while having a look at this code. Why would Thanks a lot for the clarifications! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @lobre, great questions.
I used to inject loggers as dependencies to everything but I've found that's it's overly complicated in most cases—especially for small/medium-sized projects. Simply having a
I used
The |
Beta Was this translation helpful? Give feedback.
Hi @lobre, great questions.
I used to inject loggers as dependencies to everything but I've found that's it's overly complicated in most cases—especially for small/medium-sized projects. Simply having a
log
available globally from anywhere makes things easier. I'll usually switch to an injected logger once I have a good reason.