Logging Activity is a Spring Boot application created to experiment with masking sensitive data in logs using Log4j
This project demonstrates how sensitive information can be masked at the logging framework level (not in business logic) using a reusable utility dependency.
- Application Name: logging-activity
- Application Framework: Spring Boot
- Base Package:
in.org.nnm - Logging Framework: Log4j
- Primary Goal: Mask sensitive data in application logs
│in.org.nnm
├── src/main/java
│ ├── controller
│ │ └── LoggingController.java
│ │ └── Endpoint: GET /logging/display
│ │
│ └── utils
│ └── csvparser
│ └── display()
│ └── Reads logs from a TXT file
│
├── src/main/resources
│ ├── log4j2-configurations
│ │ ├── log4j2.xml
│ │ ├── log4j2.yml
│ │ ├── log4j2.properties
│ │ └── log4j2.json
│ │
│ ├── logs.csv
│ └── application.properties
│
└── pom.xml
This project uses a custom utility for Log4j masking:
<dependency>
<groupId>in.org.nnm</groupId>
<artifactId>log4j-utils</artifactId>
<version>1.0.0</version>
</dependency>- Centralized masking logic for Log4j
- Prevents sensitive data leakage in logs
- Reusable across multiple Spring Boot applications
- Keeps business code clean and secure
- Application generates logs normally
- Log messages pass through Log4j layouts / rewrite policies
- Masking logic from log4j-utils is applied
- Sensitive data is replaced with masked values (e.g. ****)
- Only masked logs are printed or stored
This project includes four different Log4j configuration formats to experiment with and compare behavior while masking sensitive data.
| File Name | Format |
|---|---|
log4j2.xml |
XML |
log4j2.yml |
YAML |
log4j2.json |
JSON |
log4j2.properties |
Properties |
Each configuration file demonstrates:
- Console and JSON appenders
- Layout configurations
- Sensitive data masking support
- Different ways of defining Log4j settings
You can switch between configurations by updating the following property in application.properties:
logging.config=classpath:log4j2-configurations/log4j2.xml(Change the file name to test other formats)
- Java 17 or higher
- Maven
- Spring Boot
git clone https://github.com/Neel1210/logging-activity.git
cd logging-activity
mvn clean install
mvn spring-boot:runOnce the application starts, access the endpoint at:
http://localhost:8080/logging/display
- Neelesh Mehar
- Software Engineer
- Focus areas: Java, Spring Boot, Logging, Security, Clean Architecture