-
Notifications
You must be signed in to change notification settings - Fork 68
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
Make DefaultSerializerSettings non-readonly #106
Comments
@antgraf you should not change DefaultSerializerSettings. I'm not sure that the configuration system will be able to correctly read the settings for JsonSerializer. If you want to change json serializer settings then you should make GraylogSinkOptions like this var loggerConfig = new LoggerConfiguration();
loggerConfig.WriteTo.Graylog(new GraylogSinkOptions
{
ShortMessageMaxLength = 50,
MinimumLogEventLevel = LogEventLevel.Information,
Facility = "GELF",
HostnameOrAddress = "localhost",
Port = 12209,
UseGzip = false,
JsonSerializerOptions = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = new JavaScriptTestEncoder()
},
TransportType = TransportType.Udp
}); |
@whir1 Is it possible with configuration file? |
no it's not possible with config files. But i think you can use combination with configuration and startup code to make SinkOptions |
@whir1 is there an example of mixing config and runtime options? I have an impression that after instantiating it with a config there is no way to apply more changes programmatically. Thanks. |
As I understand the idea of DefaultSerializerSettings is to override JSON settings. But in the current implementation it's impossible to assign it. Changing the pre-created object is also not possible because JsonSerializerOptions uses caching and immutable state after creation (at least in .NET 7, see ConfigurationList.IsImmutable & JsonSerializerOptions.IsImmutable).
Proposal: remove "readonly" modifier, so the field could be re-assigned before a logger creation. Alternately, JsonSerializerOptions may be added as a parameter to configuration.
The text was updated successfully, but these errors were encountered: