Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason why log field should private static?

here is in C#:

private static readonly ILog log = LogManager.GetLogger(typeof (MyClass));

Not only in C# but another language i saw the same.. any thought?

like image 416
ktutnik Avatar asked Dec 07 '22 01:12

ktutnik


1 Answers

It's private because other classes should not access MyClass' log.

It's static because it doesn't depend on the class instance. (And so that it can be used by static methods)

like image 154
SLaks Avatar answered Dec 09 '22 15:12

SLaks