Logging in Integrations

Add logging to your integrations for monitoring and troubleshooting

Logging lets you monitor and troubleshoot what your integrations are doing. Weik.io collects these logs and displays them in the admin UI.

Using the weikio-log kamelet

The weikio-log kamelet is the recommended way to write logs in your integrations. Logs written with it flow directly back to the Weik.io platform, where you can filter and search them by context.

Basic usage

- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Processing order ${header.orderId}"
      loggingLevel: INFO

Logging levels

Choose a level that matches the purpose of the message:

# Informational messages about normal operation
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Created ${exchangeProperty.productionTaskKeys.size()} production tasks"
      loggingLevel: INFO

# Detailed troubleshooting information
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Request body: ${body}"
      loggingLevel: DEBUG

# Unexpected conditions that do not stop processing
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Retrying failed request, attempt ${header.attemptCount}"
      loggingLevel: WARN

# Errors that require attention
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Failed to process order: ${exception.message}"
      loggingLevel: ERROR

Why use the weikio-log kamelet

Compared to standard Camel logging, the weikio-log kamelet provides:

  • Centralized logs - Logs appear in the Weik.io dashboard.
  • Search and filtering - Filter logs by integration, agent, or time.
  • Structured storage - Logs are stored with metadata.

Using expressions in log messages

Use Apache Camel’s Simple Expression Language to include runtime values in log messages:

# Access message body
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Received payload: ${body}"
      loggingLevel: DEBUG

# Access headers
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Processing order ${header.orderId} for customer ${header.customerId}"
      loggingLevel: INFO

# Access exchange properties
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Batch contains ${exchangeProperty.recordCount} records"
      loggingLevel: INFO

# Use expressions
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Order total: ${body[total]} ${body[currency]}"
      loggingLevel: INFO

Logging at different points

Add log statements at the significant points in your flow:

- from:
    uri: "platform-http:/api/orders"
    steps:
      # Log incoming request
      - to:
          uri: kamelet:weikio-log
          parameters:
            message: "Received order request: ${body}"
            loggingLevel: DEBUG

      - unmarshal:
          json: {}

      # Log after validation
      - to:
          uri: kamelet:weikio-log
          parameters:
            message: "Validated order ${body[orderId]}"
            loggingLevel: INFO

      - to:
          uri: "sql:INSERT INTO orders (data) VALUES (:#${body})"

      # Log successful completion
      - to:
          uri: kamelet:weikio-log
          parameters:
            message: "Successfully stored order ${body[orderId]}"
            loggingLevel: INFO

Error logging

Include logging in your error handling to record failures:

- from:
    uri: "platform-http:/api/orders"
    steps:
      - doTry:
          steps:
            - unmarshal:
                json: {}
            - to:
                uri: "sql:INSERT INTO orders (data) VALUES (:#${body})"
            - to:
                uri: kamelet:weikio-log
                parameters:
                  message: "Order processed successfully"
                  loggingLevel: INFO
          doCatch:
            - exception:
                - "java.lang.Exception"
              steps:
                - to:
                    uri: kamelet:weikio-log
                    parameters:
                      message: "Failed to process order: ${exception.message}"
                      loggingLevel: ERROR
                - setHeader:
                    name: CamelHttpResponseCode
                    constant: "500"

Alternative: Camel’s built-in logging

You can also use Camel’s standard logging component:

- log:
    message: "Processing order ${header.orderId}"
    loggingLevel: INFO

Note that this component writes only to standard output. These logs are not visible in the admin UI context filters.

Future enhancement

A planned update will automatically route all native Apache Camel logs back to Weik.io. After that change, native Camel logs will be visible in the admin UI without adding the kamelet to each route.

Next steps