How to implement a PatternMaskingLayout for a LoggingEventCompositeJsonEncoder
See original GitHub issueHi. I have the following problem. I’m using the LoggingEventCompositeJsonEncoder
to generate JSON logs, but I found out that we have lots of confidential information that we want to filter out (basically just put *** in the corresponding key).
https://www.schibsted.pl/blog/logback-pattern-gdpr/
One idea here is to use this:
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="com.schibsted.payment.logback.PatternMaskingLayout">
However, this will not log everything nicely in JSON.
Is there a way to accomplish what I want?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
How to implement a PatternMaskingLayout for a ... - GitHub
I'm using the LoggingEventCompositeJsonEncoder to generate JSON logs, but I found out that we have lots of confidential information that we want ...
Read more >Mask sensitive data in logs with logback - Stack Overflow
Try this one. 1. First of all, we should create a class for handling our logs (each row) public class PatternMaskingLayout extends PatternLayout...
Read more >Anonymizing logs for GDPR using Logback pattern layout
The idea behind the configuration is to extend every logback appender you need with custom layout, in our case it is: PatternMaskingLayout which ......
Read more >Logging configuration - Puppet
By configuring logback appropriately, you get JSON-formatted log messages with event-specific fields in each message. Common fields. If you use the recommended ...
Read more >Mask Sensitive Data in Logs With Logback - Baeldung
Learn how to use the PatternLayout feature to mask sensitive data in application logs with Logback.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve written a simple version which worked for my specific needs: https://github.com/logstash/logstash-logback-encoder/pull/375.
However, I don’t feel like it’s yet great. I might need some feedback from @phasebash.
The problem is that if I try to log some specific objects (for example, I wanted to log
JSONObject
s andJSONArray
s. I ended up doing something like this in thewriteObject
method:This is clearly not a generic use and you’ll have to implement overloaded sanitize methods. I’m wondering what would be an alternative to this?
Yes definitely!
And I’d love if the logic to detect what should be masked would be customizable. And logstash-logback-encoder provided some detectors for standard use cases, I can think of three cases:
1 and 2 could potentially be combined if it’s coded such that a single field name is just a subpath with one element.
Probably need to handle masking any type of field value (e.g. number fields, string fields, array fields, and object fields.)