using system;
using system.data;
using system.configuration;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.io;
using system.threading;
namespace writelog
static public bool writeline(string datatext)
static public bool writeline(string datatext, int thelevel)
filename += @"/"+ m_fileprename + datetime.now.tostring(".yyymmdd");
//check檔案存在不
if (!file.exists(filename))
fs = new filestream(
filename,
fileaccess.write,
fileshare.none);
fs.seek(0, system.io.seekorigin.end);
sw =new streamwriter(fs, system.text.encoding.utf8);
string linetext = datetime.now.tostring("yyy-mm-dd ") + datetime.now.tostring("t") + ", " + thelevel.tostring() + ", " + datatext;
sw.writeline(linetext);
if (sw != null)
if (fs != null)
}catch (exception)
finally
if (fs != null)
}catch
m_writemutex.releasemutex();
}return ret;
}static public void writefile(string filename, byte datatext)
catch (exception)}}
}
簡單寫日誌類
public class logmanager 設定要寫入日誌的屬性 if system.io.file.exists sfileurl filestream fs new filestream sfileurl,filemode.openorcreate,fileaccess.write stre...
C 寫系統日誌
using system using system.collections.generic using system.linq using system.text using system.diagnostics 建立系統事件日誌分類 註冊事件源 比如說這個日誌 於某乙個應用程式 日誌名稱 事件列表...
C語言寫日誌功能
1 非常簡單的c語言記錄檔案功能。define crt secure no warnings include include include include include define max file len 1024 1024 獲取當前系統時間 char getnowtime in路徑設定,o...