private void ReadMiscColumnOptions(IConfigurationSection config, ColumnOptions columnOptions) { SetProperty.IfNotNull <bool>(config["disableTriggers"], (val) => columnOptions.DisableTriggers = val); SetProperty.IfNotNull <bool>(config["clusteredColumnstoreIndex"], (val) => columnOptions.ClusteredColumnstoreIndex = val); var pkName = config["primaryKeyColumnName"]; if (!string.IsNullOrEmpty(pkName)) { if (columnOptions.ClusteredColumnstoreIndex) { throw new ArgumentException("SQL Clustered Columnstore Indexes and primary key constraints are mutually exclusive."); } foreach (var standardCol in columnOptions.Store) { var stdColcolumnOptions = columnOptions.GetStandardColumnOptions(standardCol); if (pkName.Equals(stdColcolumnOptions.ColumnName, StringComparison.InvariantCultureIgnoreCase)) { columnOptions.PrimaryKey = stdColcolumnOptions; break; } } if (columnOptions.PrimaryKey == null && columnOptions.AdditionalColumns != null) { foreach (var col in columnOptions.AdditionalColumns) { if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase)) { columnOptions.PrimaryKey = col; break; } } } if (columnOptions.PrimaryKey == null) { throw new ArgumentException($"Could not match the configured primary key column name \"{pkName}\" with a data column in the table."); } } }
private static void ReadAzureManagedIdentitiesOptions(IConfigurationSection config, MSSqlServerSinkOptions sinkOptions) { SetProperty.IfNotNull <bool>(config["useAzureManagedIdentity"], val => sinkOptions.UseAzureManagedIdentity = val); SetProperty.IfNotNull <string>(config["azureServiceTokenProviderResource"], val => sinkOptions.AzureServiceTokenProviderResource = val); }
private static void ReadBatchSettings(IConfigurationSection config, MSSqlServerSinkOptions sinkOptions) { SetProperty.IfNotNull <int>(config["batchPostingLimit"], val => sinkOptions.BatchPostingLimit = val); SetProperty.IfNotNull <string>(config["batchPeriod"], val => sinkOptions.BatchPeriod = TimeSpan.Parse(val, CultureInfo.InvariantCulture)); SetProperty.IfNotNull <bool>(config["eagerlyEmitFirstEvent"], val => sinkOptions.EagerlyEmitFirstEvent = val); }
private static void ReadTableOptions(IConfigurationSection config, MSSqlServerSinkOptions sinkOptions) { SetProperty.IfNotNull <string>(config["tableName"], val => sinkOptions.TableName = val); SetProperty.IfNotNull <string>(config["schemaName"], val => sinkOptions.SchemaName = val); SetProperty.IfNotNull <bool>(config["autoCreateSqlTable"], val => sinkOptions.AutoCreateSqlTable = val); }
private void ReadStandardColumns(IConfigurationSection config, ColumnOptions columnOptions) { var section = config.GetSection("id"); if (section != null) { SetCommonColumnOptions(section, columnOptions.Id); #pragma warning disable 618 // deprecated: BigInt property SetProperty.IfNotNull <bool>(section["bigInt"], (val) => columnOptions.Id.BigInt = val); #pragma warning restore 618 } section = config.GetSection("level"); if (section != null) { SetCommonColumnOptions(section, columnOptions.Level); SetProperty.IfNotNull <bool>(section["storeAsEnum"], (val) => columnOptions.Level.StoreAsEnum = val); } section = config.GetSection("properties"); if (section != null) { SetCommonColumnOptions(section, columnOptions.Properties); SetProperty.IfNotNull <bool>(section["excludeAdditionalProperties"], (val) => columnOptions.Properties.ExcludeAdditionalProperties = val); SetProperty.IfNotNull <string>(section["dictionaryElementName"], (val) => columnOptions.Properties.DictionaryElementName = val); SetProperty.IfNotNull <string>(section["itemElementName"], (val) => columnOptions.Properties.ItemElementName = val); SetProperty.IfNotNull <bool>(section["omitDictionaryContainerElement"], (val) => columnOptions.Properties.OmitDictionaryContainerElement = val); SetProperty.IfNotNull <bool>(section["omitSequenceContainerElement"], (val) => columnOptions.Properties.OmitSequenceContainerElement = val); SetProperty.IfNotNull <bool>(section["omitStructureContainerElement"], (val) => columnOptions.Properties.OmitStructureContainerElement = val); SetProperty.IfNotNull <bool>(section["omitElementIfEmpty"], (val) => columnOptions.Properties.OmitElementIfEmpty = val); SetProperty.IfNotNull <string>(section["propertyElementName"], (val) => columnOptions.Properties.PropertyElementName = val); SetProperty.IfNotNull <string>(section["rootElementName"], (val) => columnOptions.Properties.RootElementName = val); SetProperty.IfNotNull <string>(section["sequenceElementName"], (val) => columnOptions.Properties.SequenceElementName = val); SetProperty.IfNotNull <string>(section["structureElementName"], (val) => columnOptions.Properties.StructureElementName = val); SetProperty.IfNotNull <bool>(section["usePropertyKeyAsElementName"], (val) => columnOptions.Properties.UsePropertyKeyAsElementName = val); // TODO PropertiesFilter would need a compiled Predicate<string> (high Roslyn overhead, see Serilog Config repo #106) } section = config.GetSection("timeStamp"); if (section != null) { SetCommonColumnOptions(section, columnOptions.TimeStamp); SetProperty.IfNotNull <bool>(section["convertToUtc"], (val) => columnOptions.TimeStamp.ConvertToUtc = val); } section = config.GetSection("logEvent"); if (section != null) { SetCommonColumnOptions(section, columnOptions.LogEvent); SetProperty.IfNotNull <bool>(section["excludeAdditionalProperties"], (val) => columnOptions.LogEvent.ExcludeAdditionalProperties = val); SetProperty.IfNotNull <bool>(section["excludeStandardColumns"], (val) => columnOptions.LogEvent.ExcludeStandardColumns = val); } section = config.GetSection("message"); if (section != null) { SetCommonColumnOptions(section, columnOptions.Message); } section = config.GetSection("exception"); if (section != null) { SetCommonColumnOptions(section, columnOptions.Exception); } section = config.GetSection("messageTemplate"); if (section != null) { SetCommonColumnOptions(section, columnOptions.MessageTemplate); } }
private void ReadBatchSettings(IConfigurationSection config, SinkOptions sinkOptions) { SetProperty.IfNotNull <int>(config["batchPostingLimit"], val => sinkOptions.BatchPostingLimit = val); SetProperty.IfNotNull <string>(config["batchPeriod"], val => sinkOptions.BatchPeriod = TimeSpan.Parse(val, CultureInfo.InvariantCulture)); }