If I define an object like a logger object as static in a class, then call a method like the following:
public class Manager
{
private static ClientLogManager log = new ClientLogManager();
public void Log(string Message)
{
log.Debug(string Message);
}
}
This is defined in a class library project.
My understanding is that the static variable is shared between all requests for this application, so the log object is shared. However the method Debug itself is not static, but the object is static, so there will be only one instance of this method. Is that correct?
If a lot of users are calling this code at the same time, if 2 requests are calling the log.Debug method at the same time, can the message of the 2nd request overwrite the message of the 1st request?
Also, is it better to replace this with a Singleton? wouldn't it be one Singleton object per request?
Here is the ClientLogManager code
public class ClientLogManager
{
#region Member Variables
private static readonly ILog _log = LogManager.GetLogger(typeof(ClientLogManager));
#endregion
#region Constructors
public ClientLogManager()
{
}
#endregion
#region Public Methods
public void Debug(string message)
{
_log.Debug(message);
}
#endregion
}