using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BO.Utils
|
|
{
|
|
public class LogUtil
|
|
{
|
|
private static readonly string LogFilePath = "log";
|
|
|
|
private static readonly object lockobj=new object();
|
|
|
|
public static void Error(Exception e)
|
|
{
|
|
Error(e.ToString());
|
|
}
|
|
|
|
public static void Error(string error)
|
|
{
|
|
lock (lockobj)
|
|
{
|
|
if (!Directory.Exists(LogFilePath))
|
|
{
|
|
Directory.CreateDirectory(LogFilePath);
|
|
}
|
|
var date = DateTime.Today.ToString("yyyyMMdd");
|
|
var fileName = LogFilePath+ "/" + date + ".txt";
|
|
using (var sw = new StreamWriter(fileName, true))
|
|
{
|
|
sw.WriteLine(DateTime.Now.ToString("yyyyMMdd HH:mm:ss----") + error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|