/// <summary> /// </summary> /// <param name="LoggingFolder"></param> public static void SetupStandardLogging(string LoggingFolder, bool InCommandLineMode) { if (InCommandLineMode) { // Console mode should only be showing display/warning/error messages, logs shouldn't be shown. // They also should not have datestamps etc prefixed. DisplayOutputOnly = true; MaximumVerbosity = LogLevel.Display; } if (AppVersion.Trace) { //WindowUtils.AllocConsole(); } AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; RegisterSink(new ConsoleLogSink()); RegisterSink(new FileLogSink(Path.Combine(LoggingFolder, "program.log"))); AppDomain.CurrentDomain.ProcessExit += (sender, e) => { lock (Sinks) { foreach (LogSink Sink in Sinks) { Sink.Close(); } Sinks.Clear(); } }; }
///<summary> ///Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. ///</summary> ///<filterpriority>1</filterpriority> public override void Close() { if (Sink == null) { return; } FlushShrunkIfNotEmpty(); Sink.Close(); }