What is the meaning of the log name in the common .NET protocol?

I am using the .NET common V2.0 registration framework . I get an ILog object as follows:

ILog log = LogManager.GetLogger("myLogName");

and I do not understand the meaning and meaning of the name of the journal. Does it matter if I use the same name throughout the process , or can I just use LogManager.GetCurrentClassLogger()for each class (yes, I know this is due to performance degradation).

ps: I will probably use log4net and ConsoleOutLogger.

+3
source share
2 answers

I believe that a name means everything that you want it to mean. There are two main reasons for using different names in different places:

  • (, , ).
  • , .
0

GetLogger. .

public sealed class LogManager
{
    ...
    public static ILoggerFactoryAdapter Adapter { get; set; }

    public static ILog GetLogger(string name)
    {
        return Adapter.GetLogger(name); // Adapter is  ILoggerFactoryAdapter
    }
}

public interface ILoggerFactoryAdapter
{
    // Methods
    ILog GetLogger(string name);
    ILog GetLogger(Type type);
}

log4net

public class Log4NetLoggerFactoryAdapter : ILoggerFactoryAdapter
{
  ...
  public ILog GetLogger(string name)
  {
    return new Log4NetLogger(LogManager.GetLogger(name)); // LogManager - is log4net.Logmanager
  }
}
0

Source: https://habr.com/ru/post/1784906/


All Articles