You can leverage the Log4j Framework by Apache to make changes to the message logger during application execution. In the case where you are dealing with sensitive data in your application, it is difficult to mask at the code level because so many of the libraries log data that you do not have control over the message input. What Log4j offers is a way to intercept the data before it logs it to a file by creating a Rewrite Policy.

Rewrite Policy

You need to create a Java class that implements the Apache RewritePolicy class. This will give you access to the log data before it is logged such as the logger name, level, message, throwable, etc… You will notice that you need to invoke the class as a factory method. In this case we are not passing any arguments so we just call the constructor and there is no logic involved. To pass arguments you need to annotate them with @PluginAttribute(“attributeName”) and then pass them to the constructor when instantiating the object.

#data access #logging #sensitive data #data-science

How To Mask Sensitive Data
4.75 GEEK