Logging filters for Spring WebFlux client and server request/responses

Related tags

Logging webflux-log
Overview

webflux-log

Logging filters for Spring WebFlux client and server request/responses.

Usage

To log WebClient request/response, do the following

  • specify data you want to be logged via LoggingProperties
LoggingProperties requestProperties = LoggingProperties.builder()
        .logRequestId(true).requestIdPrefix("TEST")
        .logHeaders(true).maskedHeaders("Authorization")
        .logBody(true)
        .build();

LoggingProperties responseProperties = LoggingProperties.builder()
        .logRequestId(true).requestIdPrefix("TEST")
        .logHeaders(true)
        .logBody(true)
        .build();
  • create ClientRequestLoggingFilter and ClientResponseLoggingFilter via factories
ExchangeFilterFunction requestLogFilter = ClientRequestLoggingFilterFactory.defaultFilter(requestProperties);
ExchangeFilterFunction responseLogFilter = ClientResponseLoggingFilterFactory.defaultFilter(responseProperties);
  • add filters to WebClient
WebClient.builder()
        ...
        .filter(requestLogFilter)
        .filter(responseLogFilter)
        .build();
  • log message example
REQUEST: POST http://localhost:8088/some/test/path REQ-ID: [ TEST_6dd82486 ] HEADERS: [ Accept=application/json Authorization={masked} ] BODY: [ Some request body value ]
RESPONSE: ELAPSED TIME: 233ms STATUS: 200 OK REQ-ID: [ TEST_6dd82486[ad13a534] ] HEADERS: [ Matched-Stub-Id=eccbf9ef-dabc-4659-aec6-1428db585cb7 Vary=Accept-Encoding, User-Agent Transfer-Encoding=chunked Server=Jetty(9.4.44.v20210927) ] BODY: [ response-body 123 ]

To log server request/response, do the following

  • specify data you want to be logged via LoggingProperties
LoggingProperties requestProperties = LoggingProperties.builder()
.logRequestId(true)
.logHeaders(true).maskedHeaders("Authorization")
.logBody(true)
.build();

LoggingProperties responseProperties = LoggingProperties.builder()
.logRequestId(true)
.logHeaders(true)
.logCookies(true)
.logBody(true)
.build();
  • create LoggingFilter via ServerLoggingFilterFactory
LoggingFilter requestResponseLoggingFilter = ServerLoggingFilterFactory.defaultFilter(requestProperties, responseProperties);
  • add LoggingFilter to WebFilters chain, e. g., registering it as a WebFilter bean

  • log message example

REQUEST: POST http://localhost:8080/test/endpoint REQ-ID: [ 20206022 ] HEADERS: [ accept-encoding=gzip user-agent=ReactorNetty/1.0.13 host=localhost:8080 content-type=application/json accept=application/json content-length=41 Authorization={masked} ]
REQ-ID: [ 20206022 ] BODY: [ {"value0":"WCh6dSSw","value1":"AI2D7SMs"} ]
        
RESPONSE: ELAPSED TIME: 61ms STATUS: 200 OK REQ-ID: [ 20206022 ] HEADERS: [ Content-Type=application/json;charset=UTF-8 Content-Length=50 ] COOKIES (Set-Cookie): [ ] BODY: [ {"value0":"WCh6dSSw","value1":"AI2D7SMs"}-RESPONSE ]
You might also like...

Best-of-breed OpenTracing utilities, instrumentations and extensions

OpenTracing Toolbox OpenTracing Toolbox is a collection of libraries that build on top of OpenTracing and provide extensions and plugins to existing i

Oct 15, 2022

Logstash - transport and process your logs, events, or other data

Logstash Logstash is part of the Elastic Stack along with Beats, Elasticsearch and Kibana. Logstash is a server-side data processing pipeline that ing

Jan 5, 2023

Free and open source log management

Graylog Welcome! Graylog is an open source log management platform. You can read more about the project on our website and check out the documentation

Jan 6, 2023

Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.

Apache Log4j 2 Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the

Jan 4, 2023

Best-of-breed OpenTracing utilities, instrumentations and extensions

OpenTracing Toolbox OpenTracing Toolbox is a collection of libraries that build on top of OpenTracing and provide extensions and plugins to existing i

Oct 15, 2022

Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way.

log-sourcing Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way. The basic idea is th

Apr 19, 2021

PortalLogger - Logs portals into a text file and in chat

Logs portals into a text file and in chat. Useful if afk flying under bedrock. Feel free to add to your client The logs are stored in .minecraft/ARTEMIS/PortalLogger

Dec 2, 2022

Echopraxia - Java Logging API with clean and simple structured logging and conditional & contextual features. Logback implementation based on logstash-logback-encoder.

Echopraxia Echopraxia is a Java logging API that and is designed around structured logging, rich context, and conditional logging. There is a Logback-

Nov 30, 2022

An extensible Java library for HTTP request and response logging

An extensible Java library for HTTP request and response logging

Logbook: HTTP request and response logging Logbook noun, /lɑɡ bʊk/: A book in which measurements from the ship's log are recorded, along with other sa

Dec 29, 2022

Dynamically filters JPA entities with a simple query syntax. Provides JPA/Hibernate predicates and Spring Data specifications.

Spring Filter You need a way to dynamically filter entities without any effort? Just add me to your pom.xml. Your API will gain a full featured search

Dec 13, 2022

Ferramenta de Gerenciamento de Projetos de Software utilizando a metodologia Ágil Scrum e Gamification com Webflux e Mongodb

Task Flow Application Getting started To make it easy for you to get started with GitLab, here's a list of recommended next steps. Already a pro? Just

Oct 22, 2021

Bloofi: A java implementation of multidimensional Bloom filters

Bloofi: A java implementation of multidimensional Bloom filters Bloom filters are probabilistic data structures commonly used for approximate membersh

Nov 2, 2022

🟪 DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.

🟪 DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.

DeepfakeHTTP – Your 100% static dynamic backend DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses. What are people using it

Dec 30, 2022

This is a simple realization of custom messages pre/post processing in spring-boot HTTP/Stream requests & responses

spring-boot-custom-message-converting-instances This is a simple realization of custom messages converting in spring-boot HTTP requests and responses.

Jul 22, 2022

循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

Jan 6, 2023

🔌 Simple library to manipulate HTTP requests/responses and capture network logs made by the browser using selenium tests without using any proxies

🔌 Simple library to manipulate HTTP requests/responses and capture network logs made by the browser using selenium tests without using any proxies

Simple library to manipulate HTTP requests and responses, capture the network logs made by the browser using selenium tests without using any proxies

Oct 23, 2022

Copy Regex Matches is a Burp Suite plugin to copy regex matches from selected requests and/or responses to the clipboard.

Copy Regex Matches is a Burp Suite plugin to copy regex matches from selected requests and/or responses to the clipboard.

Copy Regex Matches Copy Regex Matches is a Burp Suite plugin to copy regex matches from selected requests and/or responses to the clipboard. Install D

Dec 2, 2022

Decorating Spring Boot Reactive WebClient for tracing the request and response data for http calls.

Decorating Spring Boot Reactive WebClient for tracing the request and response data for http calls.

SpringBoot Reactive WebClient 🔍 Tracing HTTP Request through a single pane of glass Decorating Spring Boot Reactive WebClient for tracing the request

Jul 13, 2022
Owner
null
An extensible Java library for HTTP request and response logging

Logbook: HTTP request and response logging Logbook noun, /lɑɡ bʊk/: A book in which measurements from the ship's log are recorded, along with other sa

Zalando SE 1.3k Dec 29, 2022
The reliable, generic, fast and flexible logging framework for Java.

About logback Thank you for your interest in logback, the reliable, generic, fast and flexible logging library for Java. The Logback documentation can

QOS.CH Sarl 2.6k Jan 7, 2023
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 547 Dec 30, 2022
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 551 Jan 4, 2023
Simple Logging Facade for Java

About SLF4J The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging

QOS.CH Sarl 2.1k Jan 7, 2023
Log annotation for logging frameworks

Herald "Why, sometimes I've believed as many as six impossible things before breakfast." - Lewis Carroll, Alice in Wonderland. Herald provides a very

Vladislav Bauer 71 Dec 21, 2022
Highly efficient garbage-free logging framework for Java 8+

Garbage Free Log Highly efficient garbage-free logging framework for Java 8+. Use Add the following dependencies to your project: implementation 'com.

EPAM Systems 37 Dec 12, 2022
Adapts Java platform logging (System.Logger) to SLF4J 1.7.x.

avaje-slf4j-jpl Adapts Java platform logging (System.Logger) to SLF4J 1.7.x. Requires Java 11 or greater. Step 1. Add dependenc

avaje 1 Jan 18, 2022
A Java library that facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google's GNSS Logger application format.

google-gnss-logger This library facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google

Giulio Scattolin 5 Dec 21, 2022
P6Spy is a framework that enables database data to be seamlessly intercepted and logged with no code changes to the application.

p6spy P6Spy is a framework that enables database data to be seamlessly intercepted and logged with no code changes to existing application. The P6Spy

p6spy 1.8k Dec 27, 2022