在没有引入log4j.dll 的情况下,简单输出日志:
public static void ErrorLog(string mssg)
{
string FilePath = "F:/ErrorLog.txt";
StreamWriter tw = null;
try
{
if (!File.Exists(FilePath))
{
File.Create(FilePath);
}
if (System.IO.File.Exists(FilePath))
{
using (tw = System.IO.File.AppendText(FilePath))
{
tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
tw.Flush();
}
}
else
{
tw = new StreamWriter(FilePath);
tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
}
}
catch (Exception ex)
{ }
finally
{
if (tw != null)
tw.Close();
}
}