void CreateSomeLogs(int groupId) { var rand = new Random(groupId); LogSeverity severity; var logger = new LoggerFacade(Logger.Instance, "Thread [" + Thread.CurrentThread.ManagedThreadId + "]") { GroupId = groupId }; while (!StopThreads) { try { severity = (LogSeverity)rand.Next(1, 7); // 7 will generate an exception switch (severity) { case LogSeverity.Debug: logger.LogDebug("Debug Message from Group Id: " + groupId); break; case LogSeverity.Fatal: logger.LogFatal("Fatal Message from Group Id: " + groupId); break; case LogSeverity.Error: logger.LogError("Error Message from Group Id: " + groupId); break; case LogSeverity.Warning: logger.LogWarning("Warning Message from Group Id: " + groupId); break; case LogSeverity.Verbose: logger.LogVerbose("Verbose Message from Group Id: " + groupId); break; case LogSeverity.Info: logger.LogInfo("Info Message from Group Id: " + groupId); break; default: logger.LogDebug("Default Message from Group Id: " + groupId); break; } } catch (ThreadAbortException ex) { logger.LogError("Thread was aborted.", ex); break; } catch (Exception ex) { logger.LogError("Exception encountered while creating a threaded log entry.", ex); break; } Thread.Sleep(rand.Next(1000, 3000)); } logger.LogInfo("Thread Cancelled"); }