Search code examples
c#nlog

Why create NLog Logger for every class


Is there any other benefit besides being able to filter it by class later?

I'm thinking about just creating a static method in a class to have one instance of logger for all my classes to avoid having to call

logger = LogManager.GetCurrentClassLogger 

for every class.


Solution

  • There are no benefits other than the ability to configure and filter your log by class name. If you do not rely on having this ability, having one logger for all classes is a perfectly valid choice.