private void End(LogConfigSetup setup) { CheckConfigured(); IsInProgress = true; try { DetailsFormatter = setup.DetailsFormatter ?? new DetailsFormatter(); MaxMessagesPerContext = setup.MaxMessagesPerContext ?? DefaultMaxMessagesPerContext; ContextStrategy = setup.ContextStrategy ?? new CallContextStrategy(); var clientFactory = setup.ClientFactory ?? new LogCastClientFactory(); var engineFactory = setup.EngineFactory ?? new LogCastEngineFactory(); Engine = engineFactory.Create(clientFactory, DetailsFormatter); if (setup.DispatchInspectors != null) { foreach (var inspector in setup.DispatchInspectors) { Engine.RegisterInspector(inspector); } } if (setup.IsLazyInitialization) { Engine.LazyInitializer = x => LogManager.InitializeEngine(Engine); } else { LogManager.InitializeEngine(Engine); } _current = this; } catch (Exception ex) { new FileFallbackLogger(null, 0).Write(ex, "Failed to configure the logging subsystem."); throw; } finally { IsInProgress = false; } }
/// <summary> /// Use this method to configure the logging subsystem with a default configuration /// Can be called only once per process lifetime /// </summary> /// <param name="logManager">An object implementing <see cref="ILogManager"/> interface that binds /// the logging subsystem with a specific logging framework</param> /// <param name="disableLogCastEngine">Specify 'true' if you don't want to send log messages /// but still want to log them using the specified logging framework /// In this case <see cref="LogCastContext"/> will be ignored /// </param> public static void Configure(ILogManager logManager, bool disableLogCastEngine) { CheckConfigured(); if (disableLogCastEngine) { _current = new LogConfig(logManager) { DetailsFormatter = new DetailsFormatter(), Engine = new EmptyLogCastEngine(), MaxMessagesPerContext = 0, ContextStrategy = new CallContextStrategy() }; return; } var config = new LogConfig(logManager); var setup = new LogConfigSetup(config.End); setup.End(); }