4. Monitoring, Logging and Statistics

log

Version

Logs request and response messages. The messages will appear either on the console or in a log file depending on the log configuration.

Typical use cases:

  • Debugging APIs during development.
  • Operational visibility in production (metadata-only, masked values, message, body).

When supported, the log uses terminal colors to make the output easier to read and find. To overwrite the detection of color support, set the system property MEMBRANE_DISABLE_TERM_COLORS to true or false.

Syntax

log:
'$ref': <string>
body: <boolean>
category: <string>
label: <string>
language: groovy
level: trace
maskSensitive: <boolean>
message: <string>
xmlConfig: {}
log:
  '$ref': <string>
  body: <boolean>
  category: <string>
  label: <string>
  language: groovy
  level: trace
  maskSensitive: <boolean>
  message: <string>
  xmlConfig: {}

Sample

<serviceProxy port="2000">
<request>
<log />
</request>
<target host="www.predic8.de" />
</serviceProxy>
<serviceProxy port="2000">
  <request>
	<log />
  </request>
  <target host="www.predic8.de" />
</serviceProxy>

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
bodyfalsetrueWhether to include message bodies in logs.

Warning: Body logging can expose secrets or personal data. Prefer false in production.

-
categoryfalseFully qualified class name of LogInterceptor com.predic8.membrane.core.interceptor.log.LogInterceptorLogger category to use.

Allows routing logs into different appenders/targets via Logback/Log4j configuration.

-
labelfalseempty stringShort label printed with each log line to distinguish multiple log interceptors.

Useful when several APIs share the same category but you want quick visual grouping.

"After Transformation"
languagefalseSpELthe language of the 'test' conditionSpEL, groovy, jsonpath, xpath
levelfalseINFOLog level for emitted messages.

Values: TRACE, DEBUG, INFO, WARN, ERROR, FATAL

WARN
maskSensitivefalse-Whether to mask sensitive header values (e.g., Authorization, Cookies, API keys).

When enabled (default), values are replaced by ****.

-
messagefalse---

Child Structure

ElementCardinalityDescription
xmlConfig0..1

Can be used in