日志
时间:2011-05-18 来源:小羽毛的天空
最近天天都在用的写日志方法很简单几句
/// <summary>
/// 日志记录
/// </summary>
/// <param name="itype">记录日志的类型(infom、debug、waring、error)</param>
/// <param name="infom">日志等信息</param>
public static void WriteLog(string itype, string infom)
{
if (itype == "infom")
{
using (StreamWriter si = new StreamWriter("infomlog.txt", true, System.Text.Encoding.Default))
{
si.Write(DateTime.Now.ToString() + "————" + infom + "\r\n");
}
}
if (itype == "debug")
{
using (StreamWriter se = new StreamWriter("dictlog.txt", true, System.Text.Encoding.Default))
{
se.Write(DateTime.Now.ToString() + "————" + infom + "\r\n");
}
}
if (itype == "waring")
{
using (StreamWriter se = new StreamWriter("waringlog.txt", true, System.Text.Encoding.Default))
{
se.Write(DateTime.Now.ToString() + "————" + infom + "\r\n");
}
}
if (itype == "error")
{
using (StreamWriter se = new StreamWriter("errorlog.txt", true, System.Text.Encoding.Default))
{
se.Write(DateTime.Now.ToString() + "————" + infom + "\r\n");
}
}
}
相关阅读 更多 +