Skip to content

Commit

Permalink
Add configurable request logging
Browse files Browse the repository at this point in the history
  • Loading branch information
byronantak committed Oct 25, 2024
1 parent e54ee55 commit 9489fde
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.box.l10n.mojito.security;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

@Configuration
public class RequestLoggingConfig {

@Value("${l10n.logging.includesQueryString:false}")
public boolean includesQueryString;

@Value("${l10n.logging.includesHeader:false}")
public boolean includesHeader;

@Bean
@ConditionalOnProperty(value = "l10n.logging.requests.enabled", havingValue = "true")
public CommonsRequestLoggingFilter logFilter() {
CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
filter.setIncludeQueryString(includesQueryString);
filter.setIncludePayload(true);
filter.setMaxPayloadLength(10000);
filter.setIncludeHeaders(includesHeader);
filter.setAfterMessagePrefix("REQUEST DATA: ");
return filter;
}
}

0 comments on commit 9489fde

Please sign in to comment.