Answer the question
In order to leave comments, you need to log in
Logging via singleton?
Hello. There is a server to which users are connected. It follows that it is multi-threaded.
There are 2 logging methods:
1) standard (call this construct everywhere): LogManager.GetCurrentClassLogger().Debug("...");
2) mine (via singleton):
1 time:
Logger.Instance.AddLogger(new Log4NetWriter(LogManager.GetCurrentClassLogger()));
Logger.Instance.Debug("...");
Answer the question
In order to leave comments, you need to log in
Greetings.
Should be used when you want to use a separate logger for each class and the logger name will be the same as the class name.
Example of correct usage:
namespace MyNamespace
{
public class MyClass
{
private static Logger logger = LogManager.GetCurrentClassLogger();
}
}
namespace MyNamespace
{
public static class MyClass
{
private static Logger logger = LogManager.GetLogger("MyCoolLogger");//или упомянутый GetCurrentClassLogger()
public static void Debug(string message){
logger.Log(message);
}
...
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question