Skip to main content
Bumped by Community user
added 86 characters in body
Source Link

I'm making a console application that returns a lot of information directly to the console. I do this with a custom logger. Actually my logger implementation is just a frontend to print (with some extras).

The application is quite complex and I made it in DDD style, but one thing doesn't work for me - almost every business class that does something, I pass an instance of Logger through DI. First of all, this is very cumbersome, and secondly it obscures the code. Business classes have a Logger dependency that might as well be turned off, because if the action executes correctly, it doesn't return anything anyway.

The question is - do you pass the logger instance to your business classes explicitly via DI or do you have a global logger object that you use directly in the code? Or any other way? Maybe you have some rule of thumb for when DI and when global?

I'm making a console application that returns a lot of information directly to the console. I do this with a custom logger. The application is quite complex and I made it in DDD style, but one thing doesn't work for me - almost every business class that does something, I pass an instance of Logger through DI. First of all, this is very cumbersome, and secondly it obscures the code. Business classes have a Logger dependency that might as well be turned off, because if the action executes correctly, it doesn't return anything anyway.

The question is - do you pass the logger instance to your business classes explicitly via DI or do you have a global logger object that you use directly in the code? Or any other way? Maybe you have some rule of thumb for when DI and when global?

I'm making a console application that returns a lot of information directly to the console. I do this with a custom logger. Actually my logger implementation is just a frontend to print (with some extras).

The application is quite complex and I made it in DDD style, but one thing doesn't work for me - almost every business class that does something, I pass an instance of Logger through DI. First of all, this is very cumbersome, and secondly it obscures the code. Business classes have a Logger dependency that might as well be turned off, because if the action executes correctly, it doesn't return anything anyway.

The question is - do you pass the logger instance to your business classes explicitly via DI or do you have a global logger object that you use directly in the code? Or any other way? Maybe you have some rule of thumb for when DI and when global?

Source Link

Console application vs. logger

I'm making a console application that returns a lot of information directly to the console. I do this with a custom logger. The application is quite complex and I made it in DDD style, but one thing doesn't work for me - almost every business class that does something, I pass an instance of Logger through DI. First of all, this is very cumbersome, and secondly it obscures the code. Business classes have a Logger dependency that might as well be turned off, because if the action executes correctly, it doesn't return anything anyway.

The question is - do you pass the logger instance to your business classes explicitly via DI or do you have a global logger object that you use directly in the code? Or any other way? Maybe you have some rule of thumb for when DI and when global?