internal LoggerAdapter(ILog log, IProvideExecutionIds executionIdProvider, bool circumventLogicalThreadContext) { _log = log; _executionIdProvider = executionIdProvider; _circumventLogicalThreadContext = circumventLogicalThreadContext; }
/// <summary> /// Constructor accepting configuration properties and an arbitrary /// <see cref="ILog4NetRuntime"/> instance. /// </summary> /// <param name="properties">configuration properties, see <see cref="Log4NetLoggerFactoryAdapter"/> for more.</param> /// <param name="runtime">a log4net runtime adapter</param> protected Log4netLoggerFactoryAdapter(NameValueCollection properties, ILog4NetRuntime runtime) { if (runtime == null) { throw new ArgumentNullException("runtime"); } _runtime = runtime; // parse config properties string configType = ArgUtils.GetValue(properties, "configType", string.Empty).ToUpper(); string configFile = ArgUtils.GetValue(properties, "configFile", string.Empty); _circumventLogicalThreadContext = Convert.ToBoolean(ArgUtils.GetValue(properties, "circumventLogicalThreadContext", "false")); string executionIdProvider = ArgUtils.GetValue(properties, "executionIdProvider", string.Empty); if (!string.IsNullOrWhiteSpace(executionIdProvider)) { var type = Type.GetType(executionIdProvider, true, false); _executionIdProvider = (IProvideExecutionIds) Activator.CreateInstance(type); // currently not supporting any arguments - change as / when needed } // app-relative path? if (configFile.StartsWith("~/") || configFile.StartsWith("~\\")) { configFile = string.Format("{0}/{1}", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/', '\\'), configFile.Substring(2)); } if (configType == "FILE" || configType == "FILE-WATCH") { if (configFile == string.Empty) { throw new ConfigurationErrorsException("Configuration property 'configFile' must be set for log4Net configuration of type 'FILE' or 'FILE-WATCH'."); } if (!File.Exists(configFile)) { throw new ConfigurationErrorsException("log4net configuration file '" + configFile + "' does not exists"); } } switch (configType) { case "INLINE": _runtime.XmlConfiguratorConfigure(); break; case "FILE": _runtime.XmlConfiguratorConfigure(configFile); break; case "FILE-WATCH": _runtime.XmlConfiguratorConfigureAndWatch(configFile); break; case "EXTERNAL": // Log4net will be configured externally. break; default: _runtime.BasicConfiguratorConfigure(); break; } }