屠宰场客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
865 B

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);
}
}
}
}
}