简单的写文本日志方法

 

public void WriteGameLog(string msg,string logType)
{
    //建立log文件夹
    string log_path = @"C://log";
    if (!Directory.Exists(log_path))
        Directory.CreateDirectory(log_path);

    //建立log下分类文件夹
    string gameLog_path = log_path + @"//" + logType;
    if (!Directory.Exists(gameLog_path))
        Directory.CreateDirectory(gameLog_path);
    //按时间建立时间点文件
    string path = gameLog_path + @"//" + DateTime.Now.ToString("yyyy_MM_dd") + ".txt";
    File.AppendAllText(path, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + msg + Environment.NewLine);
}
相关文章
相关标签/搜索