# Grok patterns - failed to match - java logs

**URL:** <https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521>\
**Category:** Elasticsearch\
**Created:** [April 17, 2017, 3:32am UTC](https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521 "2017-04-17T03:32:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ItsMeSurajR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itsmesurajr/32/17395_2.png) [@ItsMeSurajR](https://discuss.elastic.co/u/ItsMeSurajR)\
**Post date:** [April 17, 2017, 3:32am UTC](https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521/1 "2017-04-17T03:32:33Z")

</div>

Hi all,

I'm a newbie and I learnt by watching several tutorials. I'm enjoying and sweating too!

I'm trying to match errors in my java output log. I wrote a grok pattern as below and it matches in [grokdebug.herokuapp.com](http://grokdebug.herokuapp.com) but it's not working when I config it. Can anyone tell me where I'm missing?

Much appreciated, please

Log file:

> ```
> > [04-10 02:48:26] Test case assertion error
> java.lang.AssertionError: Failed to create profile: filterTesting
> > [04-09 16:47:33] Remote callback: unable to map server sent proxy Id=97 to client side proxy object=null from idToClientProxy. 
> > [04-09 16:47:33] Remote callback: unable to map server sent proxy Id=97 to client side proxy object=null from idToClientProxy. 
> 
> ```

I need to match only the error portion of it. SO I wrote the pattern as

`\[%{GREEDYDATA:date}\] %{GREEDYDATA:FailureType}\n%{JAVACLASS:JavaClassError}(?:\:%{SPACE}%{GREEDYDATA:FailureReason})`

My simple.conf file is as follows:

```
input {
        file {
               path => "/home/surajr/Documents/java.log"                       
       }
}
filter {
        grok{
                match => { "message" => "\[%{GREEDYDATA:date}\] %{GREEDYDATA:FailureType}\n%{JAVACLASS:JavaClassError}(?:\:%{SPACE}%{GREEDYDATA:FailureReason})" }
        }

}
output{
     if [date] and [FailureType] and [JavaClassError] {
         file {
                        path => "/home/surajr/Documents/output.log"
                        codec => "plain"
                }
    }
    else {
           file {
                        path => "/home/surajr/Documents/output2.log"
                        codec => "plain"
                }
    }
}

```

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [April 18, 2017, 11:08pm UTC](https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521/2 "2017-04-18T23:08:38Z")

</div>

You should use the multiline codec. This way you don't have to deal with the /n.

[https://www.elastic.co/guide/en/logstash/current/plugins-codecs-multiline.html](https://www.elastic.co/guide/en/logstash/current/plugins-codecs-multiline.html)

---

<div class="post-metadata">

**Author:** ![ItsMeSurajR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itsmesurajr/32/17395_2.png) [@ItsMeSurajR](https://discuss.elastic.co/u/ItsMeSurajR)\
**Post date:** [April 18, 2017, 11:53pm UTC](https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521/3 "2017-04-18T23:53:33Z")

</div>

Thanks for the reply. Yes. I implemented multi line codec.

---

<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:** [May 16, 2017, 11:56pm UTC](https://discuss.elastic.co/t/grok-patterns-failed-to-match-java-logs/82521/4 "2017-05-16T23:56:42Z")

</div>

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