using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MesDataFunction
{
public partial class Log
{
static string strLogPath = Application.StartupPath + "/Log";
public static void BusinessLog(string opName, string strContentInfo)
{
try
{
// 拼日志格式
string str = string.Format("{0} {1}\r\n",
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), strContentInfo);//时间输出
string tmpLogPath = string.Format("{0}/{1}", strLogPath, DateTime.Now.ToString("yyyyMMdd"));
if (!Directory.Exists(tmpLogPath)) Directory.CreateDirectory(tmpLogPath);
StreamWriter sw = File.AppendText(string.Format("{0}/{1}.log", tmpLogPath, opName));
sw.Write(str); sw.Close();
}
catch
{
}
}
}
}
快速简单建立txt日志信息