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 ab5015a
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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.requests.includesQueryString:false}")
public boolean includesQueryString;

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

@Value("${l10n.logging.requests.includesPayload:true}")
public boolean includesPayload;

@Value("${l10n.logging.requests.maxPayloadLength:10000}")
public int maxPayloadLength;

@Value("${l10n.logging.requests.maxPayloadLength:Request Data: }")
public String afterMessagePrefix;

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

0 comments on commit ab5015a

Please sign in to comment.