# Is it possible to have a reusable template for the line codec format?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880>\
**Category:** Logstash\
**Created:** [November 30, 2018, 9:54am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880 "2018-11-30T09:54:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![naga\_kunchala](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@naga\_kunchala](https://discuss.elastic.co/u/naga_kunchala)\
**Post date:** [November 30, 2018, 9:54am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880/1 "2018-11-30T09:54:20Z")

</div>

\*\*Is it possible to have a reusable template for the line codec format ? The same is in multiple places so it would be nice to have it once so all messages are the same regardless of which file { … } it was generated from

---

<div class="post-metadata">

**Author:** ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)\
**Post date:** [November 30, 2018, 9:57am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880/2 "2018-11-30T09:57:17Z")

</div>

Can you give an example of what you hope to achieve?

---

<div class="post-metadata">

**Author:** ![naga\_kunchala](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@naga\_kunchala](https://discuss.elastic.co/u/naga_kunchala)\
**Post date:** [November 30, 2018, 10:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880/3 "2018-11-30T10:09:30Z")

</div>

output {  
stdout { }  
file {  
path =\> "/home/local/logs"  
codec =\> line { format=\>"%{message}" }  
}  
file {  
path =\> "home/local/cons.log"  
codec =\> line { format=\>"%{message}" }  
}  
file {  
path =\> "/home/local/cons.json"  
codec =\> json  
}  
if [label] == "DEBUF" or [label] == "INFO" {  
email {  
to =\> ""  
from =\> ""  
via =\> "sendmail"  
subject =\> "%{severity\_label}: %{program} %{host} %{xmessage}"

```
  }

```

file {  
path =\> "/home/local/label.log"  
codec =\> line { format=\>"%{message}" }  
}

}

}

the output filter have codec line have in multiple places. all codec lines have same format , so instead of multiple codec line is it possible single codec line for all logs.

---

<div class="post-metadata">

**Author:** ![Eniqmatic](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@Eniqmatic](https://discuss.elastic.co/u/Eniqmatic)\
**Post date:** [November 30, 2018, 10:12am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880/4 "2018-11-30T10:12:28Z")

</div>

I don't think so, but it doesn't really take long to copy and paste a few lines

---

<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:** [December 28, 2018, 10:12am UTC](https://discuss.elastic.co/t/is-it-possible-to-have-a-reusable-template-for-the-line-codec-format/158880/5 "2018-12-28T10:12:31Z")

</div>

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