private static LogWriter ConfigureLogWriter(InvocableInMemoryTraceListener inMemoryTraceListener) { // My collection of TraceListeners. I am only using one. Could add more. LogSource mainLogSource = new LogSource("MainLogSource", SourceLevels.All); mainLogSource.Listeners.Add(inMemoryTraceListener); // Assigning a non-existant LogSource for Logging Application Block Special Sources I don’t care about. LogSource nonExistantLogSource = new LogSource("Empty"); // I want all messages, of any category, to get distributed to all TraceListeners in my mainLogSource. IDictionary <string, LogSource> traceSources = new Dictionary <string, LogSource>(); foreach (LogCategories logCategory in Enum.GetValues(typeof(LogCategories))) { traceSources.Add(logCategory.ToString(), mainLogSource); } // Gluing it all together. // No filters at this time. // Not yet logging a couple of the Special Sources. return(new LogWriter( new ILogFilter[0], traceSources, nonExistantLogSource, nonExistantLogSource, mainLogSource, LogCategories.Error.ToString(), false, true)); }
static AppLogger() { _inMemoryTraceListener = ConfigureInMemoryTraceListener(); _writer = ConfigureLogWriter(_inMemoryTraceListener); }