I use Visual Studio 2019.
This error is appearing again and again while adding an ASP.NET MVC 5 controller with views using Entity Framework, I have tried many ways it doesn't remove.
My code:
namespace SingletoninMVC.logger
{
public sealed class Log : ILog
{
private Log()
{
}
private static readonly Lazy<Log> instance = new Lazy<Log>(() => new Log());
public static Log GetInstance
{
get { return instance.Value; }
}
public void LogException(string message)
{
string fileName = string.Format("{0}_{1}.log", "Exception", DateTime.Now.ToShortDateString());
string logFilePath = string.Format(@"{0}\{1}", AppDomain.CurrentDomain.BaseDirectory, fileName);
StringBuilder sb = new StringBuilder();
sb.AppendLine("----------------------------------------");
sb.AppendLine(DateTime.Now.ToString());
sb.AppendLine(message);
using (StreamWriter writer = new StreamWriter(logFilePath, true))
{
writer.Write(sb.ToString());
writer.Flush();
}
}
}
}