C#自己写的文本文件日志的实现源代码

来源:互联网 发布:ps统一肤色软件 编辑:程序博客网 时间:2024/04/29 23:30

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace MyQuery.Utils
{
    /// <summary>
    /// 日志 封装
    /// by 贾世义 2011-07-01
    /// </summary>
    public static class LogHelper
    {
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="filePre">文件名称前缀</param>
        /// <param name="message"></param>
        public static void WriteToFile(string filePre, string message)
        {
            string path = WebHelper.GetRootServerPath() + "Log";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            if (String.IsNullOrEmpty(filePre))
            {
                filePre = "log";
            }
            path += "\\" + filePre + System.DateTime.Today.ToString("yyyyMMdd") + ".txt";

            TxtHelper.WriteToFile(path, message, false);
        }
    }
}

欢迎访问:http://121.18.78.216 适易查询分析、工作流、内容管理及项目管理演示平台

原创粉丝点击