Skip to content

Releases: Yash-777/api-request-logging

v1.1.0 — AOP controller capture, RestTemplate auto-logging, SLF4J, secret masking, multipart skip, error indicators, demo filter dispatch showcase

13 Apr 08:51

Choose a tag to compare

v1.1.0 — AOP controller capture, RestTemplate auto-logging, SLF4J, secret masking,
multipart skip, error indicators, demo filter dispatch showcase

New features
────────────

  • AOP controller handler auto-capture (ControllerHandlerAspect)
    Logs "controllerHandler: UserController#listUsers" automatically for every
    @RestController / @Controller method. Zero boilerplate. Requires
    spring-boot-starter-aop on the classpath; silently skipped when absent.

  • RestTemplate auto-capture (RestTemplateLoggingBeanPostProcessor)
    Injects RestTemplateLoggingInterceptor into every Spring-managed RestTemplate
    bean. Logs outgoing request and response bodies under a timestamped key.
    Enable with: api.request.logging.rest-template.auto-capture-enabled=true

  • SLF4J logger output
    All log output now routed to a named SLF4J logger ("api.request.logging").
    Compatible with Logback, Log4j2, and any SLF4J binding. System.out retained
    as opt-in fallback via api.request.logging.logger.sysout-enabled=true.

  • Secret masking
    JSON body and header values for configured field names are replaced with
    "***MASKED***". Fixed regex to cover numeric/boolean/null JSON values
    (e.g. latitude:17.375 was previously skipped).
    Enable with: api.request.logging.mask.enabled=true

  • Multipart / binary request skip
    RequestBodyCachingFilter detects Content-Type and skips wrapping for
    image/*, audio/*, video/*, multipart/*, and application/octet-stream.
    Prevents heap pressure from buffering large file uploads.

  • Short error indicator
    When an exception is caught, the INCOMING block now includes:
    errorIndicator: "ERROR:NullPointerException"
    exceptionStacktrace: first N lines of the stack trace (default 5)
    Configurable via: api.request.logging.exception.max-lines

  • Header skip list
    api.request.logging.skip-headers=user-agent,postman-token
    Drops headers entirely before logging (distinct from mask).

  • Redirect path capture
    Reads the Location response header and logs "redirectPath" in the
    INCOMING block for 3xx responses.

  • Request body type detection
    Logs "requestBodyType: raw | form-data | binary" for every request.

  • starterRequestContextFilter safety bean
    Auto-registers OrderedRequestContextFilter at order -105 when
    @EnableWebMvc is present in the consumer app (fixes BeanCreationException
    "No thread-bound request found" with @EnableWebMvc configs
    ).

Bug fixes
─────────

  • SecretMaskingUtil: regex now matches all JSON value types — string, number,
    boolean, and null. Previously only quoted string values were masked.
  • @webfilter ignored without @ServletComponentScan: demo filters now
    registered via FilterRegistrationBean with explicit DispatcherType list.
  • @EnableWebMvc consumer compatibility: starterRequestContextFilter bean
    prevents BeanCreationException when WebMvcAutoConfiguration backs off.

Demo additions
──────────────

  • ServletOncePerRequestFilter vs SpringOncePerRequestFilter showcase:
    proves Servlet filter runs on REQUEST + FORWARD; Spring's runs once only.
  • ControllerA → RequestDispatcher.forward() → ControllerB demo
  • DashboardController → RequestDispatcher.include() → WidgetController demo
  • ApiDemoFilter: consumer filter demonstrating sendError(401) + setting
    request attribute "apilog.errorMessage" for error body capture.
  • EnableWebMVCConfig: @EnableWebMvc fixture to reproduce filter-order issue.
  • RedirectDemoController: 5 redirect variants (302, view-name, sendRedirect,
    301, external).
  • DemoConfiguration: @bean demoRestTemplate() calling Open-Meteo weather API.

Compatibility
─────────────
Spring Boot 2.0.1+ | Java 8+ | Maven Central: io.github.yash-777

v1.0.1 — plain library JAR fix

31 Mar 13:43

Choose a tag to compare

What changed

Bug fix — fat JAR packaging (#1)

Version 1.0.0 was accidentally packaged as a Spring Boot executable fat JAR.
All classes were placed under BOOT-INF/classes/ instead of at the root of
the JAR. Spring Boot's auto-configuration scanner expects classes at the JAR
root and cannot find them inside BOOT-INF/classes/, causing:

java.io.FileNotFoundException: class path resource
  [com/github/yash777/apirequestlogging/autoconfigure/
   ApiRequestLoggingAutoConfiguration.class]
  cannot be opened because it does not exist

Fix: Added <skip>true</skip> to the repackage execution in
spring-boot-maven-plugin. The JAR is now a plain library JAR with
classes at the root, as required for Spring Boot starter libraries.

Upgrade

Replace 1.0.0 with 1.0.1 in your pom.xml:

<dependency>
    <groupId>io.github.yash-777</groupId>
    <artifactId>api-request-logging-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>

No other changes are required — the API, properties, and behaviour are identical.

Links