private void OnMidnight(object sender, ElapsedEventArgs e) { try { var logFileInfo = new FileInfo(EventLogger.GetLogPath(ServiceConfig.LogPath)); //if log file size is bigger than MAX MB if ((logFileInfo.Length / 8) / 1024 > MAX_LOG_FILE_SIZE) { File.Delete(EventLogger.GetLogPath(ServiceConfig.LogPath)); } EventLogger.WriteLog("LOG RESETED", ""); } catch (Exception ex) { EventLogger.WriteLog("RESET LOG ERROR", ex.ToString()); } }