Quantcast
Channel: User bavaza - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Should I inherit the class logger when using NLog?

$
0
0

When logging from a derived class, should I inherit the class-logger instance from the base class, or instantiate a new one?

Namely, which is better:

public class Base{    private static Logger _logger = LogManager.GetCurrentClassLogger();    private void Foo()    {        _logger.Info("Hello world");    }}public class Derived : Base{    new private static Logger _logger = LogManager.GetCurrentClassLogger();    private void Fee()    {        _logger.Info("Hello world");    }}

or:

public class Base{    protected static Logger _logger = LogManager.GetCurrentClassLogger();    private void Foo()    {        _logger.Info("Hello world");    }}public class Derived : Base{    private void Fee()    {        _logger.Info("Hello world");    }}

Viewing all articles
Browse latest Browse all 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>