public class Log
{
public static bool isdebug
{
get
{
return true;
}
}
private static object _O = new object();
private static readonly string logpath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)), "XDECNByExcel.log");
public static void writeErrlog(string taskname, Exception e)
{
writelog($"执行[{taskname}]出错,ERR MSG: {e.Message},ERR STACKTRACE: {e.StackTrace}");
}
public static void writeDebuglog(string msg)
{
if (isdebug)
{
writelog(msg);
}
}
public static void writelog(string msg)
{
lock (_O)
{
File.AppendAllText(logpath, "[" + DateTime.Now.ToString() + "]: " + msg + "
");
}
}
}