elastic / ecs-dotnet

https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html
Apache License 2.0
115 stars 58 forks source link

[BUG] Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset: String '2024-08-21T15:02:36.640979-03:00' was not recognized as a valid DateTime #421

Closed ltouro closed 10 hours ago

ltouro commented 3 weeks ago

ISO 8601 format seems to not be recognized by Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset

    <PackageReference Include="Elastic.Extensions.Logging" Version="8.6.0" />
ElasticsearchLogger exception: System.FormatException: String '2024-08-21T15:02:36.640979-03:00' was not recognized as a valid DateTime.
   at System.DateTimeParse.ParseExactMultiple(ReadOnlySpan`1 s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, TimeSpan& offset)
   at System.DateTimeOffset.ParseExact(String input, String[] formats, IFormatProvider formatProvider, DateTimeStyles styles)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset(Object value, DateTimeOffset& d)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset[T](T target, Object value, Action`2 set)
   at Elastic.CommonSchema.PropDispatch.<>c.<TrySetEcsDocument>b__12_1(EcsDocument e, Object v)
   at Elastic.CommonSchema.PropDispatch.TrySetEcsDocument(EcsDocument document, String path, Object value)
   at Elastic.CommonSchema.PropDispatch.TrySet(EcsDocument document, String path, Object value)
   at Elastic.Extensions.Logging.ElasticsearchLogger.AddStateValues[TState](TState state, LogEvent logEvent)
   at Elastic.Extensions.Logging.ElasticsearchLogger.BuildLogEvent[TState](String categoryName, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Elastic.Extensions.Logging.ElasticsearchLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
ElasticsearchLogger exception: System.FormatException: String '2024-08-21T15:02:48.311780-03:00' was not recognized as a valid DateTime.
   at System.DateTimeParse.ParseExactMultiple(ReadOnlySpan`1 s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, TimeSpan& offset)
   at System.DateTimeOffset.ParseExact(String input, String[] formats, IFormatProvider formatProvider, DateTimeStyles styles)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset(Object value, DateTimeOffset& d)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset[T](T target, Object value, Action`2 set)
   at Elastic.CommonSchema.PropDispatch.<>c.<TrySetEcsDocument>b__12_1(EcsDocument e, Object v)
   at Elastic.CommonSchema.PropDispatch.TrySetEcsDocument(EcsDocument document, String path, Object value)
   at Elastic.CommonSchema.PropDispatch.TrySet(EcsDocument document, String path, Object value)
   at Elastic.Extensions.Logging.ElasticsearchLogger.AddStateValues[TState](TState state, LogEvent logEvent)
   at Elastic.Extensions.Logging.ElasticsearchLogger.BuildLogEvent[TState](String categoryName, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Elastic.Extensions.Logging.ElasticsearchLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
ElasticsearchLogger exception: System.FormatException: String '2024-08-21T15:02:48.750264-03:00' was not recognized as a valid DateTime.
   at System.DateTimeParse.ParseExactMultiple(ReadOnlySpan`1 s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, TimeSpan& offset)
   at System.DateTimeOffset.ParseExact(String input, String[] formats, IFormatProvider formatProvider, DateTimeStyles styles)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset(Object value, DateTimeOffset& d)
   at Elastic.CommonSchema.PropDispatch.TrySetDateTimeOffset[T](T target, Object value, Action`2 set)
   at Elastic.CommonSchema.PropDispatch.<>c.<TrySetEcsDocument>b__12_1(EcsDocument e, Object v)
   at Elastic.CommonSchema.PropDispatch.TrySetEcsDocument(EcsDocument document, String path, Object value)
   at Elastic.CommonSchema.PropDispatch.TrySet(EcsDocument document, String path, Object value)
   at Elastic.Extensions.Logging.ElasticsearchLogger.AddStateValues[TState](TState state, LogEvent logEvent)
   at Elastic.Extensions.Logging.ElasticsearchLogger.BuildLogEvent[TState](String categoryName, LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Elastic.Extensions.Logging.ElasticsearchLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)