protected override void OnFormClosing(FormClosingEventArgs e) { // Final log entry EasyLogger.Info("Closing down..."); // Dispose EasyLogger EasyLogger.RemoveListener(); }
private void Custom_Click(object sender, EventArgs e) { // Backup the log files in this location EasyLogger.BackupLogs(EasyLogger.LogDirectory + "TEST_CUSTOM.log"); // Need to dispose so that we can set our new log location EasyLogger.RemoveListener(); // Need to add a listener again EasyLogger.AddListener(EasyLogger.LogFile); // Log something EasyLogger.Info("TEST: The log file path is: " + EasyLogger.LogFile); }
static void Main(string[] args) { if (Default.LoggingEnabled) { EasyLogger.BackupLogs(EasyLogger.LogFile, 30); EasyLogger.AddListener(EasyLogger.LogFile); } if (Default.UpgradeRequired) { Default.Upgrade(); Default.UpgradeRequired = false; Default.Save(); Default.Reload(); } if (Default.FirstRun) { Default.FirstRun = false; Default.Save(); Default.Reload(); SettingsForm settings = new SettingsForm(); settings.ShowDialog(); Environment.Exit(0); } if (args.Length > 0) { try { string A0 = args[0].ToLower(); if (args[0] == "/optimize" || args[0] == "-optimize") { StartLightCleanup(); } else { StartLightCleanup(); } } catch (Exception ex) { EasyLogger.Info(ex.Message); } } else { // Run Settings and Close SettingsForm settings = new SettingsForm(); settings.ShowDialog(); } EasyLogger.Info("********************* END OF OPTIMIZATIONS *********************"); EasyLogger.RemoveListener(); #if DEBUG using (StreamReader sr = File.OpenText(EasyLogger.LogFile)) { string lines = sr.ReadToEnd(); if (lines.ToLower().Contains("[error]")) { MessageBox.Show("The log file contains errors!", "Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Warning); Process.Start(EasyLogger.LogDirectory); } } #endif Environment.Exit(0); }