# ElasticSearch .NET DateTime parse failed

**URL:** <https://discuss.elastic.co/t/elasticsearch-net-datetime-parse-failed/123757>\
**Category:** Elasticsearch\
**Created:** [March 13, 2018, 2:58pm UTC](https://discuss.elastic.co/t/elasticsearch-net-datetime-parse-failed/123757 "2018-03-13T14:58:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schrader](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Schrader](https://discuss.elastic.co/u/Schrader)\
**Post date:** [March 13, 2018, 2:58pm UTC](https://discuss.elastic.co/t/elasticsearch-net-datetime-parse-failed/123757/1 "2018-03-13T14:58:57Z")

</div>

I want to parse my Json-Log into Logstash -\> ElasticSearch and use it in my .Net-Core Application with NEST / [ElasticSearch.NET](http://ElasticSearch.NET).

My Log-File:

`{"LogDate:":"2018-01-07T16:17:00.171Z", "ID":"1","LogLevel":"WARNING"}`

My logstahs-config:

```
input 
{ 
  file
  {
   path => "C:/Log/ESTest/*.json"
   ignore_older => 86400
   start_position => "beginning"
  }
}

filter
{
  json
  {
   source => "message"
  }
}

output 
{
  stdout { codec => rubydebug }
  elasticsearch 
{ 
    index => "log"
    hosts => ["localhost:9200"]
    }
}

```

Console-output shows, that the fields got parsed well.

```
{
"path" => " ****",
"LogLevel" => "WARNING",
  "@version" => "1",
   "message" => "{\"LogDate:\":\"2018-01-07T16:17:00.171Z\", \"ID\":\"1\",\"LogLevel\":\"WARNING\"}\r",
        "ID" => "1",
"@timestamp" => 2018-03-13T13:44:04.879Z,
  "LogDate:" => "2018-01-07T16:17:00.171Z",
      "host" => " ****"
}

```

Even in Kibana, i saw, that every field from this JSON-string got parsed. If i go to my .NET-Core Application and crete my Query to get my Log (just an Example).

```
public class log
  {
      public DateTimeOffset LogDate { get; set; }
      public int ID { get; set; }
      public string LogLevel { get; set; }
      public Guid GUID { get; set; }
      public string Path { get; set; }
      public string Order { get; set; }
      public string Host { get; set; }
  }

var search = client.Search<log>(s => s         
.AllTypes()
.Index("log")  
.From(0)
.Size(1000)
 );

```

Each Value was parsed, except the LogDate-field. LogDate is empty and after i try to change the type of Log Date, the effect stay the same.

```
LogDate {01.01.0001 00:00:00 +00:00} System.DateTimeOffset
LogDate {01.01.0001 00:00:00} System.DateTime (type was changed)
```

---

<div class="post-metadata">

**Author:** ![Schrader](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Schrader](https://discuss.elastic.co/u/Schrader)\
**Post date:** [March 13, 2018, 4:34pm UTC](https://discuss.elastic.co/t/elasticsearch-net-datetime-parse-failed/123757/2 "2018-03-13T16:34:49Z")

</div>

My fault!

**"LogDate:"** :"2018-01-07T16:17:00.171Z"

to

**"LogDate"** :"2018-01-07T16:17:00.171Z"  
and its working like a charm.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 10, 2018, 4:34pm UTC](https://discuss.elastic.co/t/elasticsearch-net-datetime-parse-failed/123757/3 "2018-04-10T16:34:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
