首页 > 其他分享 >LogHelper

LogHelper

时间:2023-06-26 11:23:10浏览次数:21  
标签:string filePath System static using message 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);

        }

    }
}

 

标签:string,filePath,System,static,using,message,LogHelper
From: https://www.cnblogs.com/zyx321/p/17505169.html

相关文章

  • LogHelper
    usingSystem;usingSystem.IO;usingSystem.Text;namespaceZB.QueueSys.Common{publicclassLogHelper{//privatestaticLogHelperinstance......