# How to handle different logs in logstash server

**URL:** <https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247>\
**Category:** Logstash\
**Created:** [December 7, 2016, 6:26am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247 "2016-12-07T06:26:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![houfan](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@houfan](https://discuss.elastic.co/u/houfan)\
**Post date:** [December 7, 2016, 6:26am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247/1 "2016-12-07T06:26:13Z")

</div>

currently,,I want to send nginx\_access.log and nginx\_error.log to logstash server.here is the filebeat.yml configuration,I don't know whether I am right or not.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/4/4685b5790612c5a101cc219a3086b22de08d05ae.png)

and this is the nginx\_access log format:  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/a/ab11167cdebabf5dfb47261e253ecf7649796817.png)

eeeeee.............I don't know how to configure logstash.conf in logstash server,to separate them and treat different logs in different ways.  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/b/bfead3ba7b6eeb8961d92b33a3181e3e978aa9ea.png)  
this configuration above is the wrong my example ....I searched a lot,still don't get a clue.  
appreciate a lot ,if you could help

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 7, 2016, 6:34am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247/2 "2016-12-07T06:34:17Z")

</div>

Please don't post pictures of text, they are difficult to read and some people may not be even able to see them.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 7, 2016, 6:35am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247/3 "2016-12-07T06:35:35Z")

</div>

You're on the right track with the conditional, but you can't wrap just `codec => "json"` since that's not a filter. Instead, wrap a json filter with your conditional:

```nohighlight
if ... {
  json {
    source => "message"
  }
}

```

---

<div class="post-metadata">

**Author:** ![houfan](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@houfan](https://discuss.elastic.co/u/houfan)\
**Post date:** [December 7, 2016, 6:46am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247/4 "2016-12-07T06:46:00Z")

</div>

oh! really thanks .solved my problem so easily:smiley:

---

<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:** [January 4, 2017, 6:46am UTC](https://discuss.elastic.co/t/how-to-handle-different-logs-in-logstash-server/68247/5 "2017-01-04T06:46:00Z")

</div>

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