Log4j2 how to log tags

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:

    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

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