You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Oliver Flege (JIRA)" <ji...@apache.org> on 2013/10/08 20:00:45 UTC

[jira] [Created] (LOG4J2-418) Support default value for missing key in map-based pattern

Oliver Flege created LOG4J2-418:
-----------------------------------

             Summary: Support default value for missing key in map-based pattern
                 Key: LOG4J2-418
                 URL: https://issues.apache.org/jira/browse/LOG4J2-418
             Project: Log4j 2
          Issue Type: Improvement
            Reporter: Oliver Flege
            Priority: Minor


%X{key} and %K{key} render the value found for key in the thread context map or MapMessage, respectively. If the key is not contained in the map, the pattern evaluates to "" (empty string).   
A default value for missing values can currently only be defined by using $${ctx:key} and defining a property named "key" with the desired default value. Drawbacks: ${ctx:key} has to be parsed and evaluated for each message and the pattern does not support conversion specifiers (for alignment, fixed width, etc). 
The proposed improvement would be to support an optional default value that can be specified in the pattern, e.g. %X{key:-defaultValue}   



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org