You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
DateOnly and DateTime objects are formatted in the log message using ambiguous formatting, and it does not seem possible to specify a custom formatter.
This could be either dd/mm or mm/dd (and perhaps which one it is varies depending on the locale of the system where I am running my application). I would like dates to be formatted in ISO 8601 for consistency and to facilitate further analysis of log messages from ElasticSearch.
For comparison, with the Serilog Console logger I can pass in a custom formatter:
.WriteTo.Console(
formatProvider: new ISO8601DateFormatter(),
...
Describe the solution you'd like
Allow passing in a formatProvider like the other Serilog sinks do
Describe alternatives you've considered
Expanding the documents in Kibana to look at the fields corresponding to the date/datetimes (the fields are rendered in ISO 8601), however this is very time consuming
Possibly switching to Serilog.Sinks.Elasticsearch since this appears to support the formatProvider
The text was updated successfully, but these errors were encountered:
RenderMessage is this method of Serilog LogEvent: public string RenderMessage(IFormatProvider? formatProvider = null)
I suspect that passing in a IFormatProvider here (instead of null) would work. Perhaps include IFormatProvider in IEcsTextFormatterConfiguration? Then it could be set on ElasticsearchSinkOptions.TextFormatting during application start, e.g.
.WriteTo.Elasticsearch(
new[] { new Uri(elasticUri) },
opts =>
{
opts.DataStream = new DataStreamName("logs", envName, "IBDataService");
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.TextFormatting = new EcsTextFormatterConfiguration
{
FormatProvider = new ISO8601DateFormatter(),
};
});
ECS integration/library project(s):
Elastic.Serilog.Sinks
Is your feature request related to a problem? Please describe.
DateOnly and DateTime objects are formatted in the log message using ambiguous formatting, and it does not seem possible to specify a custom formatter.
Consider the following:
This results in two documents in ElasticSearch with the following strings in the
message
property:This could be either dd/mm or mm/dd (and perhaps which one it is varies depending on the locale of the system where I am running my application). I would like dates to be formatted in ISO 8601 for consistency and to facilitate further analysis of log messages from ElasticSearch.
For comparison, with the Serilog Console logger I can pass in a custom formatter:
The logs are rendered according to the formatter:
Describe the solution you'd like
Allow passing in a formatProvider like the other Serilog sinks do
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: