4 ms·
Declaring "I need an ILogger" is the easy part. The complicated part is the configuration related to which ILogger implementation will be injected at runtime.
by vbsteven 8y ago
Declaring "I need an ILogger" is the easy part. The complicated part is the configuration related to which ILogger implementation will be injected at runtime.
This can depend on several things like configuration properties, environment variables, libraries loaded, feature flags enabled, etc
edit: also, you don't always want to manually pass the argument to every function. At application startup you typically want to build a full graph of objects with all the dependencies "wired up". The big complicated frameworks (Spring for example) read in a bunch of configuration, resolve all dependencies, and then construct the graph for you.