Skip to content

Aspect Oriented Logging library for Java Applications.

License

Notifications You must be signed in to change notification settings

sejpalsaurabh/logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logging

Aspect Oriented Logging library for Java Applications.

Configuration

.yaml

com:
    sejpalsaurabh:
        logging:
            common:
                # Default Value : true
                masking-enabled: true
                
                # For Default Values Please See Section : Commonly masked Fields
                # Below fields will be masked from all model classes annotated with @LogProperties
                masked-fields: 
                  - firstname
                  - lastname
                  - email
                  - sin

.properties

# Default Value : true
com.sejpalsaurabh.logging.common.masking-enabled=true

# For Default Values Please See Section : Commonly masked Fields
# Below fields will be masked from all model classes annotated with @LogProperties
com.sejpalsaurabh.logging.common.masked-fields=firstname, lastname, email, sin

Commonly masked Fields

Below fields will be masked if

  • com.sejpalsaurabh.logging.common.masking-enabled=true
  • com.sejpalsaurabh.logging.common.masked-fields property not configured explicitly.

These fields will be masked if they are declared as properties in the class annotated with @LogProperties

I am in the process of collecting more PII Fields, This list will be updated soon.

password, credit-card, phone, phone-number, 
postalcode, address, username, passcode, sin,
firstname, lastname, street, city, province, 
email, pincode, phonenumber, apartment, unit,
gender, dob, mobile, passport, company, organization, state

Annotations

Method Level

@EnableEntryExitLogger

Usage
package com.example.api.controller;

import com.sejpalsaurabh.logging.annotation.EnableEntryExitLogger;

public class UserController {
  
  @EnableEntryExitLogger
  @RequestMapping("/users/{id}")
  public UserDTO get(@PathVariable String id) {
    logger.info("UserId : {}", id);
    return new UserDTO();
  }
  
}
logs
Starting execution for method get() of UserController.
UserId : 638ab169c3423e459d3c06c7
Completed execution for method get() of UserController.

@EnableExecutionTimeLogger

Usage
package com.example.api.controller;

import com.sejpalsaurabh.logging.annotation.EnableExecutionTimeLogger;

public class UserController {
  
  @EnableExecutionTimeLogger
  @RequestMapping("/users/{id}")
  public UserDTO get(@PathVariable String id) {
    logger.info("UserId : {}", id);
    return new UserDTO();
  }
  
}
logs
Starting execution for method get() of UserController.
UserId : 638ab169c3423e459d3c06c7
Completed execution for method get() of UserController in 4 ms.

Field Level

@LogProperties

Usage
package com.example.model;

import com.sejpalsaurabh.logging.annotation.LogProperties;

@LogProperties
public class UserDTO {

  // Fields Declarations
  // Getters and Setters
  // toString()
  // equals() and hashCode()

}
logs [masking enabled]

if com.sejpalsaurabh.logging.common.masking-enabled=true

method createUser, class UserController, args : [[UserDTO { id = null, firstName = ********, lastName = ********, name = Nate Payne, gender = ********, genderShort = M, email = ********, sin = ********, phone = ********}]]
logs [masking disabled]

if com.sejpalsaurabh.logging.common.masking-enabled=false

method createUser, class UserController, args : [[UserDTO { id = null, firstName = John, lastName = Doe, name = John Doe, gender = Male, genderShort = M, email = [email protected], sin = 123-456-7890, phone = 1-123-456-7890}]]

Upcoming Changes

  • Variable Masking using Annotations.
  • Method Level Annotation for Logging Arguments.
  • Make library more configurable to get log patterns using properties.
  • Disable Logger for Specific Environments.

About

Aspect Oriented Logging library for Java Applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages