Skip to content

Can JsonTemplateLayout output JSON boolean values? #2482

Answered by vy
aabmass asked this question in Q&A
Discussion options

You must be logged in to vote

@aabmass, I don't think this is possible using PatternResolver – see its resolve() method uses JsonWriter#writeString(), which effectively will encode the PatternLayout output. There are a couple of approaches I can think of to address your use case:

Create your own event template resolver

✓ Complexity: 1/10
✓ You will have the full control
✓ Doesn't require a change on the Log4j side
❌ You need to deliver Java code next to the Log4j configuration

This is something you can easily do yourself.

Add a flag to PatternResolver to inject PatternLayout output without encoding it

✓ Complexity: 1/10
❌ Requires a change on the Log4j side

I am not a big fan of PatternResolver in general. It literall…

Replies: 1 comment 3 replies

Comment options

vy
Apr 18, 2024
Collaborator

You must be logged in to vote
3 replies
@aabmass
Comment options

@vy
Comment options

vy Apr 18, 2024
Collaborator

@aabmass
Comment options

Answer selected by aabmass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants