Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why create NLog Logger for every class

Tags:

c#

nlog

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.

like image 672
Jake Avatar asked Dec 05 '25 03:12

Jake


1 Answers

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.

like image 121
Sergey Kalinichenko Avatar answered Dec 06 '25 17:12

Sergey Kalinichenko