4. Monitoring, Logging and Statistics

log

Version

Logs request and response messages to the console or a log file, depending on the logging configuration. By default it writes the start line, headers, and body of each message, with sensitive header values masked. Set message to log the result of an expression instead of the full dump:

 flow:
   - log:
       message: Received ${method} ${path}
 
Streamed bodies are logged chunk by chunk. Output uses terminal colors per log level where supported; set the system property MEMBRANE_DISABLE_TERM_COLORS to true or false to override color detection. See the examples under examples/logging.

Example Configuration

api:
port: 2000
flow:
- log:
level: INFO
body: false
target:
url: https://api.predic8.de
api:
   port: 2000
   flow:
     - log:
         level: INFO
         body: false
   target:
     url: https://api.predic8.de

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: {}

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"
languagefalseSpELScripting language used to evaluate the value expression.SpEL | groovy | jsonpath | xpath
levelfalseINFOLog level for emitted messages.

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

WARN
maskSensitivefalsetrueWhether to mask sensitive header values such as Authorization, cookies, and API keys, replacing them with ****.-
messagefalse-Expression whose result is logged instead of the full message dump. Evaluated in the configured language against the current exchange.Received ${method} ${path}

Child Structure

ElementCardinalityDescription
xmlConfig0..1XML namespace declarations for XPath expressions in the value.

Can be used in