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

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 适易查询分析、工作流、内容管理及项目管理演示平台

你可能感兴趣的:(文本文件)