C#:写日志函数
public static void WriteLog( string strLog ) { string strDate = DateTime.Now.ToString( g_strDateFormate ); string strLogDir = AppDomain.CurrentDomain.BaseDirectory + "Log\\SysLog\\"; if ( !Directory.Exists( strLogDir ) ) Directory.CreateDirectory( strLogDir ); string strDateTime = DateTime.Now.ToString( g_strDateTimeFormate_2 ); strLog = string.Format( "[{0}] {1}\r\n", strDateTime, strLog ); string strLogFilePath = string.Format( "{0}/{1}.txt", strLogDir, strDate ); File.AppendAllText( strLogFilePath, strLog ); }
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。