/// <summary> /// 开始初始化数据日志 /// </summary> /// <param name="config">数据日志配置信息</param> public virtual void Initialize(DataLoggingConfig config) { LoggingAdapterConfig adapterConfig = new LoggingAdapterConfig() { Enabled = config.Enabled, AdapterType = config.AdapterType }; SetLoggingFromAdapterConfig(adapterConfig); }
/// <summary> /// 从日志适配器配置节点初始化日志适配器 /// </summary> /// <param name="config">日志适配器配置节点</param> protected virtual void SetLoggingFromAdapterConfig(LoggingAdapterConfig config) { config.CheckNotNull("config"); if (!config.Enabled) { return; } ILoggerAdapter adapter = ServiceProvider.GetService(config.AdapterType) as ILoggerAdapter; if (adapter == null) { return; } LogManager.AddLoggerAdapter(adapter); }
/// <summary> /// 从日志适配器配置节点初始化日志适配器 /// </summary> /// <param name="config">日志适配器配置节点</param> protected virtual void SetLoggingFromAdapterConfig(LoggingAdapterConfig config) { config.CheckNotNull("config"); if (!config.Enabled) { return; } ILoggerAdapter adapter = Activator.CreateInstance(config.AdapterType) as ILoggerAdapter; if (adapter == null) { return; } LogManager.AddLoggerAdapter(adapter); }