Skip to content

LoveAndCode/spring-cloud-gateway-access-log-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-cloud-gateway-access-log-starter

Simple Spring Cloud Gateway Access Log starter

Build

./gradlew clean build -x test

Property

gateway:
  accesslog:
    enabled: true # enable or disable logging, default value is true.
    timeZone: Asia/Seoul # log datetime zone setting, default is UTC

Custom Access User Information Resolver

public interface AccessUserInformationResolver {
	String resolveAccessUserInformation(ServerWebExchange serverWebExchange);
}

AccessUserInformationResolver is a class that helps you leave user or client information in the access log. For example, if you want to leave session information for a user or client in all request logs, you can leave it through the AccessUserInformationResolver class.

Example

  • Implement the AccessUserInformationResolver interface and register it as a Spring Bean.
package com.tistory.johnmark.springgateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import com.github.loveandcode.accesslog.AccessUserInformationResolver;

@SpringBootApplication
public class SpringGatewayApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringGatewayApplication.class, args);
	}

	@Bean
	public AccessUserInformationResolver accessUserInformationResolver() {
		return serverWebExchange -> "ANONYMOUS";
	}
}
  • Example Log Image gatewayAccessLogExample

Future Plan

  • Maven repository Support
  • Request Response Log Filter
  • Sensitive data masking processing option

About

Spring Cloud Gateway Access Log Custom Starter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages