2
votes

I use NLog in my application. I have facade Logging that has private static Logger, so there is just one Logger in entire application. Like this:

 public class Logging
 {
        private static Logger _logger;
        //... constructors and methods
 }

But I read in Nlog documentation that 'one logger per class' approach is recommended, so you easily get point exception came from. So each class would have:

private static Logger _logger;

But that way every class would be coupled to NLog's Logger and LogManager class. What is best way to implement 'one logger per class' in this situation?

1

1 Answers

2
votes

If you don't create a logger for each class, then you can't filter easily the messages in the config. Also if you use a helper class, then is still (indirect) coupled?

You can decouple NLog by using Common Logging. I has some up- and downsides, see faq.