I noticed there are at least two ways to write logs in Umbraco. One way is using the LogHelper
class, and the other is to use directly the methods of the instance obtained with log4net.LogManager.GetLogger
method. Needless to say that LogHelper uses log4net itself, too.
I added a custom log appender, set the file destination of the appender to be the custom file (different than the default one) and tried both ways, and noticed that the results in log are more or less the same. LogHelper's entry looks like this:
ERROR ProjectName.Controllers.Backoffice.DataController - [P4876/T1/D2] Test
while the entry that log4net makes looks like this:
ERROR ProjectName.Controllers.Backoffice.DataController - Test
However, when I searched for posts about logging on Umbraco, I often found examples of using log4net directly, rather than using the LogHelper class provided by Umbraco CMS.
So basically, are there any good reasons developers should use one way instead of the other, or is it simply the matter of preference of using methods of the library instead of using CMS-provided helper class (or the other way around - helper before the library)?