LogHelper
using Microsoft.AspNetCore.Hosting; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PT.Common { public class LogHelper { static string Path = Directory.GetCurrentDirectory(); private static void Log(string filePath, string message) { using (StreamWriter streamWriter = new StreamWriter(filePath, true)) { streamWriter.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + message); streamWriter.Close(); } } public static void DebugLog(string message) { string filePath = Path + "\\DebugLog_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"; Log(filePath, message); } public static void ErrorLog(string message) { string filePath = Path + "\\ErrorLog_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"; Log(filePath, message); } } }