My solution has multiple projects. I have this below log wrapper class in a class library project. The dll of class library is referred in other projects so i can get use of this wrapper class.
But I coudnt access the _Logger or _Log in my other projects to pass the data to write to log. What am i missing here ?
public class LoggerManager
{
public static LoggerManager _Logger;
public static ILog _log;
public LoggerManager()
{
Init();
}
public static LoggerManager Instance
{
get
{
if (_Logger == null)
{
_Logger = new LoggerManager();
}
return _Logger;
}
}
private void Init()
{
_log = LogManager.GetLogger(typeof(Program));
XmlConfigurator.Configure();
}
public void Error(Exception ex, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
{
if (_log == null)
{
Init();
}
_log.Error(string.Format("Error from Method : {0} in file {1} at line {2}", memberName, filePath, lineNumber), ex);
}
}