You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2020/05/29 09:13:13 UTC

[GitHub] [logging-log4j2] gagoman opened a new pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

gagoman opened a new pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362


   ### Description
   
   `Log4jJsonObjectMapper` [has `JsonInclude.Include.NON_EMPTY` enabled](https://github.com/apache/logging-log4j2/blob/log4j-2.13.3/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/Log4jJsonObjectMapper.java) but it is not working at the moment - keys with empty values are still present in output. It is caused by [bug in `jackson-databind`](https://github.com/FasterXML/jackson-databind/pull/2615) which I have fixed. Fix was released as part of `jackson-databind:2.11.x`.
   
   ### Why LOG4J2-2749?
   
   I feel this fix will address user request.
   
   ### Issue itself
   
   #### `log4j2.xml`
   
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <Configuration status="WARN">
       <Appenders>
           <Console name="Console" target="SYSTEM_OUT">
               <JsonLayout compact="true" properties="true">
                   <KeyValuePair key="empty" value="${ctx:empty:-}"/>
               </JsonLayout>
           </Console>
       </Appenders>
       <Loggers>
           <Root level="DEBUG">
               <AppenderRef ref="Console"/>
           </Root>
       </Loggers>
   </Configuration>
   ```
   
   #### `Main.java`
   
   ```
   import org.apache.logging.log4j.LogManager;
   import org.apache.logging.log4j.Logger;
   
   public class Main {
       private static final Logger logger = LogManager.getLogger();
   
       public static void main(String[] args) {
           logger.info("info");
       }
   }
   ```
   
   #### Output
   
   ```
   {"instant":{"epochSecond":1590743485,"nanoOfSecond":93000000},"thread":"main","level":"INFO","loggerName":"org.apache.logging.log4j.core.Main","message":"info","endOfBatch":false,"loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger","contextMap":{},"threadId":1,"threadPriority":5,"empty":""}
   ```
   
   ### Notes
   
   * I have chosen `release-2.x` while I have actually developed a patch on `2.13.3` tag. I can rebase to any other brach, just let me know which one


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] gagoman commented on pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

Posted by GitBox <gi...@apache.org>.
gagoman commented on pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362#issuecomment-651456762


   @vy sorry for a ping. Any chance to get this merged?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] vy commented on pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

Posted by GitBox <gi...@apache.org>.
vy commented on pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362#issuecomment-651978776


   Hey @gagoman! We already have the Jackson version upgrade along with another change (#335) waiting for its last review by @rgoers. Nevertheless, your changes include a test, which is good. Hence I am merging it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] vy commented on pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

Posted by GitBox <gi...@apache.org>.
vy commented on pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362#issuecomment-635907456


   Thanks for the patch @gagoman! `release-2.x` builds are failing right now due to some other problem. Once they got fixed, I will merge the PR.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] vy merged pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

Posted by GitBox <gi...@apache.org>.
vy merged pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] gagoman commented on pull request #362: LOG4J2-2749 - fix JSON Layout output containing empty values while configured otherwise

Posted by GitBox <gi...@apache.org>.
gagoman commented on pull request #362:
URL: https://github.com/apache/logging-log4j2/pull/362#issuecomment-640276744


   Awesome, thanks! Please let me know if any changes or rebase to other branch is required.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org