[ 
https://issues.apache.org/jira/browse/LOG4J2-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16871756#comment-16871756
 ] 

Ralph Goers commented on LOG4J2-2641:
-------------------------------------

Peter, are you wanting all the log entries to show up like this or just some?  
Why do you want it to be explicit in code? Generally it is better to have the 
application just log stuff without worrying too much about how it is going to 
be rendered.  It sounds like what you are wanting to do is pass in JSON and a 
message and have Log4j merge those. The JsonLayout will do that but it converts 
the whole LogEvent to JSON, so you would also see the timestamp, logging level, 
etc as part of the JSON.

> How to Log object entries outside the message entry
> ---------------------------------------------------
>
>                 Key: LOG4J2-2641
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2641
>             Project: Log4j 2
>          Issue Type: Question
>            Reporter: Peter Podniesinski
>            Priority: Trivial
>
> Hi Team. I could use some advice how to craft a log statement that prints 
> both a String Message along with a request json details.
> If I do something like this it gets stringified and shows up in the 
> `_message_` field in Logstash.
> {code:java}
> logger.info("Create Account Application. Request: {}", 
> gson.toJson(depositApplicationRequest));`{code}
>  
>  
> Ideally I want this to show up looking like:
>  
> {code:java}
> { request: ...,
>   message: 'Create Account Application' }{code}
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to