Update Card Number Masker authored by Popescu Petre's avatar Popescu Petre
...@@ -17,6 +17,57 @@ The masker does not change the length of the logged message. ...@@ -17,6 +17,57 @@ The masker does not change the length of the logged message.
Depending on the machine, the masker can take up to a few hundred milliseconds to mask 100.000 lines. The benchmark was executed on a Core i7-7700k. The average duration was: 157ms. The benchmark can be run using the `CardMaskerPerformanceTest` from the `masker` module. Depending on the machine, the masker can take up to a few hundred milliseconds to mask 100.000 lines. The benchmark was executed on a Core i7-7700k. The average duration was: 157ms. The benchmark can be run using the `CardMaskerPerformanceTest` from the `masker` module.
##Advanced Integration
When the `CardNumberMasker` is used together with the `Log4jMaskingLayout`, additional configuration options are enabled.
### Configuration options
- startKeep - integer value - Indicates the number of unmasked digits from the start of the PAN
- endKeep - integer value - Indicates the number of unmasked digits from the end of the PAN
- luhnCheck - boolean - If LUHN check on the PAN is performed prior to masking. Potential PANs which fail LUHN check are *NOT* masked. Luhn checking increases overhead since additional processing is performed.
### Example Log4j2 Integration
```xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="tech.petrepopescu.logging">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<!--<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level - %msk%n"/>-->
<Log4jMaskingLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level - %m%n">
<CardNumberMasker startKeep="4" endKeep="4" luhnCheck="true"/>
</Log4jMaskingLayout>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
```
### Example Logback Integration
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="tech.petrepopescu.logging.MaskingLayoutEncoder">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<masker class="tech.petrepopescu.logging.maskers.LogbackCardNumberMasker">
<startKeep>3</startKeep>
<endKeep>5</endKeep>
<luhnCheck>true</luhnCheck>
</masker>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
## Basic Integration
### Configuration options ### Configuration options
The card number masker allows for two configuration options: The card number masker allows for two configuration options:
... ...
......