# Log4j2 how to log tags

**URL:** <https://discuss.elastic.co/t/log4j2-how-to-log-tags/265987>\
**Category:** Elasticsearch\
**Created:** [March 2, 2021, 4:45pm UTC](https://discuss.elastic.co/t/log4j2-how-to-log-tags/265987 "2021-03-02T16:45:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pippobaudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pippobaudo/32/77329_2.png) [@pippobaudo](https://discuss.elastic.co/u/pippobaudo)\
**Post date:** [March 2, 2021, 4:45pm UTC](https://discuss.elastic.co/t/log4j2-how-to-log-tags/265987/1 "2021-03-02T16:45:55Z")

</div>

Hi, I'm trying to log the elastic field "tags" in a java app. Im using the java library log4j2 and I used the following code:

```auto
    List<String> tag_example = new ArrayList();
    tag_example.add("local");
    tag_example.add("example");

    logger.info(new StringMapMessage()
        .with("tags", tag_example);

```

but I think this may not be the right way to do it as instead of writing a Json with an array of keys, it just writes out in the log file the value as a simple string.

obtained:  
` "tags":"[local,example]"`

wanted:  
` "tags" : ["local","example"]`

Also I'm using filebeat to load the data to kibana, so I was wondering if is there a way to solve this problem by parsing the data during the import?  
I've been looking for a solution for several days but haven't been able to find a solution. Hoping that someone could help me.

Thanks

---

<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:** [March 30, 2021, 4:46pm UTC](https://discuss.elastic.co/t/log4j2-how-to-log-tags/265987/2 "2021-03-30T16:46:41Z")

</div>

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