{
string[] Item = new string[4];
Item[0] = Log["ErrorSource"].ToString();
Item[1] = ((DateTime)Log["DateTime"]).ToString(ApplicationSettings.DateTimeFormat);
Item[2] = Log["Exception"].ToString();
Item[3] = Log["Message"].ToString();
lstExceptionList.Items.Add(new ListViewItem(Item));
}
}//清空日志列表
void CancelSearch_Click(object sender, EventArgs e)
{
CancelSearch =
MessageBox.Show("Are you sure to cancel the searching operation?", "Advanced FTP Server",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
}//取消日志搜索
写入日志方法:
namespace AdvancedFTPServer
{
internal enum LogSource
{
HTTP, FTP
}
internal class ApplicationLog
{
static FileStream LogStream;
static StreamWriter Log;
static string LogFilePath;
internal static bool EnableLogging = true;
[MethodImpl(MethodImplOptions.Synchronized)]
internal static void Write(LogSource Source, Exception Ex)
{
if (Ex == null || !EnableLogging) return;
if (Ex.InnerException != null) Ex = Ex.InnerException;
try
{
if (!Directory.Exists(ApplicationSettings.DataPath + "Logs\\"))
Directory.CreateDirectory(ApplicationSettings.DataPath + "Logs\\");
LogFilePath = ApplicationSettings.DataPath + "Logs\\LOG." + DateTime.Today.ToString("yyyy-MM-dd") + ".EXCEPTION";
LogStream = new FileStream(LogFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
Log = new StreamWriter(LogStream, Encoding.UTF8);
- 上一篇:造币机械生产车间信息管理系统分析与研究
- 下一篇:C#的家庭理财系统软件设计+ER图
-
-
-
-
-
-
-
电站锅炉暖风器设计任务书
河岸冲刷和泥沙淤积的监测国内外研究现状
杂拟谷盗体内共生菌沃尔...
十二层带中心支撑钢结构...
酸性水汽提装置总汽提塔设计+CAD图纸
java+mysql车辆管理系统的设计+源代码
当代大学生慈善意识研究+文献综述
乳业同业并购式全产业链...
大众媒体对公共政策制定的影响
中考体育项目与体育教学合理结合的研究