private void InitializeLogSystem() { string curr = DirHandler.Instance.CurrentDirectory; string logConfigFile = Path.Combine(curr, Ids.CONFIG_DIR, Ids.LOG_CONFIG_FILE); if (string.IsNullOrEmpty(logConfigFile) || !File.Exists(logConfigFile)) { // Unable to find log configuration file. So let's fall back upon default targets - Console and Log. Trace.WriteLine("Unable to locate the log configuration file - using default settings."); LogInitializationData log = new LogInitializationData { Active = true, TraceLevel = LogLevel.VERYHIGH, Filename = Path.Combine(curr, Ids.LOG_FILE) }; ConsoleInitializationData console = new ConsoleInitializationData { Active = true, TraceLevel = LogLevel.VERYHIGH, Filter = { DebugEnabled = false } }; Out.Create(log); Out.Create(console); } else { // Log configuration file found, so log system will be based upon the settings defined in config file. try { Out.LoadApplicationConfigFile(new FileInfo(logConfigFile)); } catch (BaseException e) { Trace.WriteLine("Failed to load log configuration file, {0}", logConfigFile); Trace.WriteLine("Error description: \n{0}", e.ExceptionSummary()); return; } try { // Start monitoring the log configuration file - changes are identified on file save occurrence. Out.StartApplicationConfigMonitor(logConfigFile, Out.LASTWRITE); } catch (BaseException e) { Trace.WriteLine("Failed to start the file monitor for monitoring the log configuration file, {0}. Continuing without monitoring the log configuration file.", logConfigFile); Trace.WriteLine("Error description: \n{0}", e.ExceptionSummary()); } } }
private void InitializeLogSystem() { string curr = DirHandler.Instance.CurrentDirectory; string logConfigFile = Path.Combine(curr, Ids.CONFIG_DIR, Ids.LOG_CONFIG_FILE); if (string.IsNullOrEmpty(logConfigFile) || !File.Exists(logConfigFile)) { // Unable to find log configuration file. So let's fall back upon default targets - Console and Log. Trace.WriteLine("Unable to locate the log configuration file - using default settings."); LogInitializationData log = new LogInitializationData { Active = true, TraceLevel = LogLevel.VERYHIGH, Filename = Path.Combine(curr, Ids.LOG_FILE) }; ConsoleInitializationData console = new ConsoleInitializationData { Active = true, TraceLevel = LogLevel.VERYHIGH, Filter = {DebugEnabled = false} }; Out.Create(log); Out.Create(console); } else { // Log configuration file found, so log system will be based upon the settings defined in config file. try { Out.LoadApplicationConfigFile(new FileInfo(logConfigFile)); } catch (BaseException e) { Trace.WriteLine("Failed to load log configuration file, {0}", logConfigFile); Trace.WriteLine("Error description: \n{0}", e.ExceptionSummary()); return; } try { // Start monitoring the log configuration file - changes are identified on file save occurrence. Out.StartApplicationConfigMonitor(logConfigFile, Out.LASTWRITE); } catch (BaseException e) { Trace.WriteLine("Failed to start the file monitor for monitoring the log configuration file, {0}. Continuing without monitoring the log configuration file.", logConfigFile); Trace.WriteLine("Error description: \n{0}", e.ExceptionSummary()); } } }