Logging in Integrations

Add logging to your integrations for monitoring and troubleshooting

Logging provides visibility into your integration flows for monitoring and troubleshooting. Weik.io provides a centralized logging system that allows administrators to view logs by context in the admin UI.

Using the weikio-log Kamelet

The weikio-log kamelet is the recommended way to log in integrations. Logs created with this kamelet flow back to the Weik.io platform where admins can view them by context.

Basic Usage

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

Logging Levels

Use appropriate logging levels based on the information type:

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

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

# Warning messages
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Retrying failed request, attempt ${header.attemptCount}"
      loggingLevel: WARN

# Error messages
- to:
    uri: kamelet:weikio-log
    parameters:
      message: "Failed to process order: ${exception.message}"
      loggingLevel: ERROR

Benefits of weikio-log Kamelet

The weikio-log kamelet provides several advantages over standard logging:

  • Centralized viewing - Logs flow back to the Weik.io platform
  • Context-based filtering - Admins can view logs by integration, agent, or time period
  • Structured logging - Logs are stored with metadata for better analysis
  • Admin UI integration - View and search logs directly in the admin interface

Using Expressions in Log Messages

Log messages support Apache Camel’s Simple Expression Language for dynamic content:

# 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 logging at key points in your integration 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

Combine logging with 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

While the weikio-log kamelet is recommended, you can still use Camel’s built-in logging component:

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

The built-in logging component writes to standard output but does not provide the same admin UI integration for viewing logs by context.

Future Enhancement

In the future, all logs created by Apache Camel will automatically flow back to Weik.io, providing complete visibility into integration execution without requiring explicit logging steps.

What’s Next