Configuring log4j log for sensitive data

I have a class that contains confidential information (credit card information, phone numbers, etc.).

I want this class to be able to pass in log4j, but it should hide certain information.

If I have a UserInformation class that has getPhoneNumber, getCreditCardNumber methods, how can I configure log4j or this class to hide numbers correctly.

I want the credit card number to be displayed as xxxx-xxxx-xxxx-1234, and the phone number to be displayed as xxxx-xxx-xxx, given that these will be 1234-1234-1234-1234 and 1234-567-890

thank

+3
source share
3 answers

, , . , ... - ..

, , , , :

  • , , getter UserInformation, .
  • toString UserInformation, .
+5

.

, String , .

+4

. , , Obfuscated-ClassName, , ( ) . , , - .

:

, getPhoneNumberForLogging()/getObfuscatedPhoneNumber()? (, , , , /, "" , - , ?)

, - .

0

Source: https://habr.com/ru/post/1745085/


All Articles