# ECSEncoder - Add the possibility to process or transform the messages

**URL:** <https://discuss.elastic.co/t/ecsencoder-add-the-possibility-to-process-or-transform-the-messages/293204>\
**Category:** Logs\
**Created:** [December 30, 2021, 1:25pm UTC](https://discuss.elastic.co/t/ecsencoder-add-the-possibility-to-process-or-transform-the-messages/293204 "2021-12-30T13:25:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fpena](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fpena/32/99697_2.png) [@fpena](https://discuss.elastic.co/u/fpena)\
**Post date:** [December 30, 2021, 1:25pm UTC](https://discuss.elastic.co/t/ecsencoder-add-the-possibility-to-process-or-transform-the-messages/293204/1 "2021-12-30T13:25:33Z")

</div>

I need to be able to transform some messages. For example obfuscate some information. I want to be able to do that at the encoder level and not before on several components.

Now a days, the encode method add the message using  
`event.getFormattedMessage()`

It could be very useful if we can add something similar to the following at the ECSEncoder class:

```auto
/**
 * Subclasses can override this to format the message (for example to obfuscate some fields.)
 * @param event The event to be logged
 * @return The message processed. By default, this method return the message without any modification
 */
protected String processMessage (ILoggingEvent event){
   return event.getFormattedMessage();
}

```

And at the encode method

`EcsJsonSerializer.serializeFormattedMessage(builder, processMessage(event));`

What do you think?

The method name could be process, transform, or just getMessage...

---

<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 27, 2022, 1:26pm UTC](https://discuss.elastic.co/t/ecsencoder-add-the-possibility-to-process-or-transform-the-messages/293204/2 "2022-01-27T13:26:12Z")

</div>

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