LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub
CONCERNS

Request and Response Dump

This is a handler that dumps the entire request and response into a log file. It should only be used in development mode for debugging purposes as it is very slow.

Introduction

This handler can log HTTP request/response info based on configuration.

This is a generic dump handler that may be useful for troubleshooting in a developing/testing environment.

The dump request/response log file should be configured in logback.xml.

The dumping request/response info format can be default format or json format depending on the configuration.

Configuration

The output fields are populated based on the config file dump.yml and here is an example.

# controls how to dump entire request and response to log file. not recommended
# on production if performance is important
enabled: true
# indent size for logging info
indentSize: 4
# use json style or not, if use json, indentSize option will be useless
useJson: false
# if "request: false", disable dumping requests.
request:
  headers: true
  # filter for headers
  filteredHeaders:
  - Postman-Token
  - X-Correlation-Id
  cookies: true
  #filter for cookies
  filteredCookies:
  - Cookie_Gmail
  queryParameters: true
  #filter for queryParameters
  filteredQueryParameters:
  - itemId
  - a
  body: true

response:
  headers: true
  cookies: true
  body: true
  statusCode: true

Option explanation:
request: is the root of request settings
  headers: if true will enable logging headers of REQUEST   filteredHeaders: list of Headers you want to filter out.
  cookies: if true will enable logging cookies of REQUEST
  filteredCookies: list of Cookies you want to filter out.
  queryParameters: if true will enable logging queryParameters of REQUEST
  filteredQueryParameters: list of query parameters you want to filter out.   body: if true will enable logging request body

response: is the root of response settings
  headers: if true will enable logging headers of RESPONSE   filteredHeaders: list of Headers you want to filter out.
  cookies: if true will enable logging cookies of RESPONSE
  filteredCookies: list of Cookies you want to filter out.
  statusCode: if true will enable logging status code of RESPONSE
  body: if true will enable logging response body

Logback config

The following is an example of the appender defined in the logback.xml or logback-test.xml

    <appender name="dump" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>target/dump.log</file> <!-- logfile location -->
        <encoder>
            <pattern>%-5level [%thread] %date{ISO8601} %X{sId} %X{cId} %F:%L - %msg%n
            </pattern> <!-- the layout pattern used to format log entries -->
            <immediateFlush>true</immediateFlush>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>target/test.log.%i.zip</fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>5</maxIndex> <!-- max number of archived logs that are kept -->
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>200MB
            </maxFileSize> <!-- The size of the logfile that triggers a switch to a new logfile, and the current one archived -->
        </triggeringPolicy>
    </appender>

Logging example

INFO  [XNIO-1 task-3] 2018-12-11 12:20:47,525  7t9TA_UuTNyIQ4BqBVAung DumpHelper.java:23 - Http request/response information:
request:
    cookies:
        Youtube:
            Youtube: abc@youtube
            domain:
            path:
            expires: 
        username:
            username: Balloon
            domain:
            path:
            expires: 
    headers:
        Accept: */*
        cache-control: no-cache
        accept-encoding: gzip, deflate
        User-Agent: PostmanRuntime/7.4.0
        Connection: keep-alive
        Content-Type: application/json
        cookie: Youtube=abc@youtube; [email protected]; username=Balloon
        content-length: 43
        Host: localhost:8443
    queryParameters:
        aString: 1
        anInteger: "1"
response:
    body: {"content":null,"id":"1"}
    headers:
        Server: L
        Content-Length: 25
        Date: Tue, 11 Dec 2018 17:20:47 GMT
    statusCode: 200

Customized Handler

For some users that need special dump logic or other channels to redirect the dump to, they can create their dump handler and replace the default audit handler in server.yml or handler.yml depending on how you wire your middleware handlers in your application.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Request and Response Dump” was last updated: April 5, 2021: Issue246 (#256) (50b1c10)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute