# Logging from within Ruby Filter

**URL:** https://discuss.elastic.co/t/logging-from-within-ruby-filter/127983
**Category:** Logstash
**Created:** [April 13, 2018, 1:27pm UTC](https://discuss.elastic.co/t/logging-from-within-ruby-filter/127983 "2018-04-13T13:27:04Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)
#### Post date: [April 18, 2018, 8:44am UTC](https://discuss.elastic.co/t/logging-from-within-ruby-filter/127983/3 "2018-04-18T08:44:23Z")

</div>

You can!!

```auto
  ruby {
    code => '
      event.set("[file-suffix]", event.get("[file-suffix]") + 5.5)
      logger.info("the file-suffix is:", "value" => event.get("[file-suffix]"))
    '
  }

```

logs this

```auto
[2018-04-18T09:34:55,590][INFO][logstash.filters.ruby] the file-suffix is: {"value"=>13.5}

```

you can use `logger.error()`, `logger.warn()`, `logger.info()`, `logger.debug()`, `logger.trace()`  
Each of these methods has the same arguments `<string>`, `<hash>` (optional)  
The hash is written as `<string> => <any object>`. You do not need to wrap the hash argument in the Ruby {} bracket although you can if you want.

---

_[View the full topic](https://discuss.elastic.co/t/logging-from-within-ruby-filter/127983)._
