Is JsonLayout allow to manipulate logevent such as PatternLayout? #1814
-
Hello, I just wonder is there a any possible way to manipulating log event such as masking with JsonLayout. I found LogEventPatternConverter class has a format method that signed with abstract but i couldn't similiar with JsonLayout. So my question that is there any possible way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
In the JSON template layout you can reuse all pattern converters using the {
"$resolver": "pattern"
"pattern": "%replace{%m}{(\\d{4})-\\d{4}-\\d{4}-(\\d{4})}{\\1-XXXX-XXXX-\\2}"
} could mask a common credit card number format in the message. Edit: As remarked by Gary an Volkan, this is an example. In real production code private data shouldn't even be logged. |
Beta Was this translation helpful? Give feedback.
-
@Sangaibisi, as @ppkarwasz indicated, please use |
Beta Was this translation helpful? Give feedback.
-
When I am trying to use JsonTemplateLayout, I am getting this error while application starting deploy. My log4j2.xml configuration below. What could be the problem? main ERROR Console contains an invalid element or attribute "JsonTemplateLayout"
|
Beta Was this translation helpful? Give feedback.
@Sangaibisi, I think you might need to re-think your approach here. Let me elaborate on that.
Assume you have no restrictions on the schema. You might end up having documents as follows:
Sounds far fetched? Certainly not. Consider the following statements:
I can share more ed…