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
org.apache.logging.log4j.Logger;
public class Main {

       private static final Logger LOGGER = LogManager.getLogger(Main.class);

       public static void main(String[] args) {


            String message = "{\"line_id\": 12,\"play_name\": \"Jeus\"}";
            LOGGER.info(message);

        }
 }

output is:

{
 "timeMillis":1502361394238,
 "thread":"main",
 "level":"INFO",
 "loggerName":"com.jeus.logger.json.loggerjson.Main",
 "message":"{\"line_id\": 12,\"play_name\": \"Jeus\"}",
 "endOfBatch":false,
 "loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger",
 "contextMap":[

 ],
 "threadId":1,
 "threadPriority":5,
 "source":{
    "class":"com.jeus.logger.json.loggerjson.Main",
    "method":"main",
    "file":"Main.java",
    "line":62
    }
 }

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
<https://stackoverflow.com/questions/45611509/add-json-object-to-log4j2-when-is-jsonlayout?noredirect=1#comment78217774_45611509>


thank you for attention

Reply via email to