Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/create1st/logback-masked-fields
Logback layout to obscure confidential or secure information
https://github.com/create1st/logback-masked-fields
logback logging
Last synced: about 7 hours ago
JSON representation
Logback layout to obscure confidential or secure information
- Host: GitHub
- URL: https://github.com/create1st/logback-masked-fields
- Owner: create1st
- License: apache-2.0
- Created: 2021-04-23T22:05:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T20:02:23.000Z (almost 2 years ago)
- Last Synced: 2023-06-30T03:13:56.725Z (over 1 year ago)
- Topics: logback, logging
- Language: Java
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logback-masked-fields
Logback layout to obscure confidential or secure informationMaven
```xmlcom.craftandtechnology
logback-masked-fields
1.3.0```
Gradle
```kotlin
implementation("com.craftandtechnology:logback-masked-fields:1.3.0")
```Each class containing confidential information should have a dedicated formatter defined and this formatter shall be part of the Logback configuration
Sample argument formatter
```java
public class UserDataFormatter implements ArgumentFormatter {
private final PatternArgumentFormatter patternArgumentFormatter = new PatternArgumentFormatter(CONFIDENTIAL_DATA_REGEX);@Override
public Class> getSupportedClass() {
return UserData.class;
}@Override
public Object formatArgument(Object argument) {
return patternArgumentFormatter.formatArgument(argument);
}
}
```Sample Logback configuration
```xml
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
com.craftandtechnology.logging.ConfidentialDataFormatter
com.craftandtechnology.logging.UserDataFormatter
```
```Java
public class MaskingPatternLayoutDemoTest {
private final static Logger logger = LoggerFactory.getLogger(MaskingPatternLayoutDemoTest.class);@Test
void simpleTestOutput() {
logger.info("Test : {}", userData());
}
}
``````log
11:31:25.878 [Test worker] INFO c.c.MaskingPatternLayoutDemoTest - Test : UserData(confidentialData=ConfidentialData(clientId=*****, clientName=*****), nonConfidentialData=NonConfidentalData(transactionId=someTransactionId, amount=10, transactionDate=2021-04-24))
```