The JSON layout outputs the log event in JSON, the event message is just a
string in that event, in this case, it is escaped following the JSON rules
to remain a string.

If you want a JSON object back out of the event message you will have to
parse it out of that string.

Feel free to provide a PR on GitHub if you want to add an option to allow
for a JSON object as the log message. I am not sure if it would be accepted
though as it is quite different from the current design.

Thoughts from the community?


On Aug 11, 2017 07:53, "Jeus Geek" <alkhand...@gmail.com> wrote:

i will show JSON object as a JSON object in log4j2 when is that configed
JSONLayout .

JSON object:

{"line_id": 12,"play_name":"Jeus"}

import org.apache.logging.log4j.LogManager;import
public class Main {

       private static final Logger LOGGER = LogManager.getLogger(Main.

       public static void main(String[] args) {

            String message = "{\"line_id\": 12,\"play_name\": \"Jeus\"}";


output is:

 "message":"{\"line_id\": 12,\"play_name\": \"Jeus\"}",


but i will show message as a json object same this:

 "message":{"line_id": 12,"play_name":"Jeus"},

you can see more detail about my problem in stackOverflow

thank you for attention

Reply via email to