Skip to content

omitEmptyFields doesn't work with %property(ENV_VAR) #760

Answered by brenuart
ziomill asked this question in Q&A
Discussion options

You must be logged in to vote

The Pattern json provider is using a standard Logback PatternLayout under the hood to resolve placeholders and converters in the pattern string. The resulting string is then converted into JSON and added to the final result. The omitEmptyFields property works by telling Jackson to omit fields whose value is considered empty.

When a property does not exist, the %property{} converter returns null and unfortunately the PatternLayout appends this value "asis" to its internal StringBuilder. So in your case your pattern is converted into the string {"container-namespace":"null"} before it is transformed into a valid JSON structure by Jackson. As you case see, the property is not null but is ass…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ziomill
Comment options

Answer selected by ziomill
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants