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 );
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章