//private static string startpath = "c:\\rs data\\";
private static string startpath = environment.currentdirectory;
#region "工具函式區"
///
/// 寫入log
///
///
public static void writelog(string smessage)
/*log檔日期格式*/
string year = string.format("", datetime.now);
string month = string.format("", datetime.now);
string day = string.format("", datetime.now);
string time = year + "_" + month + "_" + day;
/*檢查log資料夾內的年資料夾是否存在*/
if (!directory.exists(path.combine(startpath, "log\\" + year)))
/*檢查log資料夾內的年資料夾內的月資料夾是否存在*/
if (!directory.exists(path.combine(startpath, "log\\" + year + "\\" + month)))
/*寫入文字檔*/
/*訊息前加入時、分、秒與辨識字首*/
string logformat = datetime.now.tostring("yyyy-mm-dd hh:mm:ss") + " ==> ";
using (streamwriter sw = new streamwriter(path.combine(startpath + "\\log\\" + year + "\\" + month, time + ".log"), true))
}#endregion
MySQL支援按年月日查詢
在業務環境中,總是想要篩選出不同時間條件下的資料,例如我只想查詢當天資料,當月資料或者本年資料。於是就想通過mysql自帶的幾個時間函式進行簡單的實現。select from cars location where year create time year now and month create...
進行日期年月日的加減
data lv date b like sy datum.data date ruzi like sy datum.call function rp calc date in interval exporting date date ruzi days 0 天數加n或者減n 不加也不減 寫0 mon...
nginx日誌定時切割 按年月日
2 宣告乙個獨特的log format並命名 在下面的server location,我們就可以引用 mylog 在server段中,這樣來宣告 nginx允許針對不同的server做不同的log 有的web伺服器不支援,如lighttp access log logs access 8080.lo...