sanitizeHeader

fun sanitizeHeader(predicate: (String) -> Boolean)

Redacts headers whose name satisfies predicate from log output.

Can be called multiple times to register several predicates — a header is redacted if any predicate returns true. The Authorization header is always redacted regardless of the configured predicates.

Example:

logging {
level = LogLevel.BODY
sanitizeHeader { it.equals("Cookie", ignoreCase = true) }
sanitizeHeader { it.startsWith("X-Secret-", ignoreCase = true) }
}

Parameters

predicate

Returns true to redact the header with the given name