-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible read the columnOptions from JSON configuration #109
Comments
I would like to know if there is a solution for this. |
@Jenan there is currently no way to specify the column options in JSON format. You cannot mix configuration for the same sink both in code and in config file, but you can configure the "global" Minimum Level in config file, and the SQLServer sink in code. This would mean :
{
"Serilog": {
"MinimumLevel": "Error"
}
}
var columnOptions = new ColumnOptions();
// Don't include the Properties XML column.
columnOptions.Store.Remove(StandardColumn.Properties);
// Do include the log event data as JSON.
columnOptions.Store.Add(StandardColumn.LogEvent);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(.... the configurationBuilder.AddJson(...).Build() part)
.WriteTo.MSSqlServer(Configuration.GetConnectionString("DbContext"), "Log", columnOptions: columnOptions,
restrictedToMinimumLevel: LogEventLevel.Error)
.CreateLogger(); The workaround, if you want to be able to configure the connection string and the restrictedToMinimumLevel is to load it your self from the settings, and pass it around in the C# code ... I hope this helps ! |
This is now possible with the latest SQL sink and Serilog.Settings.Configuration packages ( |
Could somebody share an example of JSON configuration (in dev version) of removing standard column from store and adding new custom column in AdditionalDataColumns collection ? |
How can I use these lines via JSON configuration:
I have tried something like this - but it doesn't work:
Thanks |
Hello,
I have tried to use following configuration structure:
Read configuration above from JSON settings:
How can I specify the columnOptions settings in JSON or how combine the columnOptions with JSON configuration?
I want to be able to change the MinimumLevel from configuration file.
Thank you.
The text was updated successfully, but these errors were encountered: