It's possible to add a new column in a Serilog Table in Azure table Storage for logging new extra field like accountID or login Name?
I think it's possible to add a new column but its possible to pass extra fields in Serilog like i said for the new added columns? How i can define that in Startup.cs or web.config? Thanks
This is my configuration in web.config:
<add key="serilog:using:AzureTableStorage" value="Serilog.Sinks.AzureTableStorage" />
<add key="serilog:write-to:AzureTableStorageWithProperties.connectionString" value="DefaultEndpointsProtocol=https;AccountName=MyAccountName;AccountKey=MyAccountKey;EndpointSuffix=core.windows.net" />
<add key="serilog:write-to:AzureTableStorage.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
<add key="serilog:write-to:AzureTableStorageWithProperties.storageTableName" value="Serilog" />
startup.cs configuration:
Log.Logger = new LoggerConfiguration()
.ReadFrom.AppSettings()
.CreateLogger();
If you want to add additional properties when you write log to azure table storage with Serilog, you need to call
Enrich.FromLogContext()andLogContext.PushProperty. With the two methods, your application will add additional properties to Azure table. For more details, please refer to the documentFor example