Logging in Integrations

Add logging to your integrations for monitoring and troubleshooting

Logging gives you a way to see what your integrations are actually doing instead of guessing when things break. Weik.io catches these logs and displays them in the admin UI.

Using the weikio-log Kamelet

The weikio-log kamelet is the easiest way to write logs in your integrations. When you use it, the logs 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

Pick a level that matches what you’re trying to communicate:

# General what's-happening-now messages
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Created ${exchangeProperty.productionTaskKeys.size()} production tasks"
      loggingLevel: INFO

# Deep-in-the-weeds troubleshooting
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Request body: ${body}"
      loggingLevel: DEBUG

# Something looks weird but we can keep going
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Retrying failed request, attempt ${header.attemptCount}"
      loggingLevel: WARN

# We have a problem
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Failed to process order: ${exception.message}"
      loggingLevel: ERROR

Why use the weikio-log Kamelet?

You could just use standard Camel logging, but the weikio-log kamelet makes life a lot easier:

  • It’s centralized - Logs show up right in the Weik.io dashboard.
  • It’s searchable - You can filter by integration, agent, or time without grepping through flat files.
  • It’s structured - Everything gets stored with proper metadata.

Using Expressions in Log Messages

You can use Apache Camel’s Simple Expression Language to make your logs actually useful instead of just printing “Got a message”:

# 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

You’ll usually want to drop a log statement in whenever something important happens 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

Logs are most useful when things go wrong. Here’s how to wire them into your error handling:

- 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

If you really want to, you can still use Camel’s standard logging component:

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

Just keep in mind that this will only write to standard output. You won’t be able to see these logs in the admin UI context filters.

Future Enhancement

We’re working on an update that will automatically route all native Apache Camel logs back to Weik.io. Once that lands, you’ll get the best of both worlds without explicitly adding the kamelet everywhere.

What’s Next