Cameleer

Log component

The log component writes each message that reaches it to the log, with control over the level and which parts (body, headers, properties) are shown.

Scheme: log: · Crate: cameleer-core · Cargo feature: none, always included (build features) · Consumer: no · Producer: yes · Apache Camel: Log

When to use it

  • See what flows through a route while developing or debugging.
  • Keep an audit trail of the messages an AI agent route sends and receives (showHeaders=true).
  • Log throughput instead of every message on busy routes (groupSize or groupInterval).

For a free-text log line inside a route, the log EIP step (- log: "...") is shorter.

URI format

text
log:loggerName[?options]

Example

yaml example: log-debug-orders
- route:
    id: debug-orders
    from:
      uri: direct:orders
      steps:
        - to:
            uri: log:orders
            parameters:
              level: DEBUG
              showHeaders: true
              showBodyType: false
              maxChars: 500
        - setBody:
            simple: "logged ${body}"

Each message produces a line such as Exchange[ExchangePattern: InOut, Headers: {region=EU}, Body: order-1] on the orders logger at DEBUG.

Rust DSL

rust
use cameleer_core::prelude::*;

pub fn routes(ctx: &CamelContext) -> Result<()> {
    ctx.add_routes(|b| {
        b.from("direct:orders")
            .route_id("debug-orders")
            .to("log:orders?level=DEBUG&showHeaders=true&showBodyType=false&maxChars=500")
            .set_body(simple("logged ${body}"));
    })
}

Options

optiondefaultdescription
levelINFOTRACE, DEBUG, INFO, WARN, ERROR or OFF.
showAllfalseShow everything below.
showExchangeIdfalseShow the exchange id.
showExchangePatterntrueShow InOnly / InOut.
showPropertiesfalseShow exchange properties.
showHeadersfalseShow message headers.
showBodytrueShow the body.
showBodyTypetrueShow the body type, as the Java class name Camel would show (java.lang.String, ...).
showExceptiontrueShow the exception of a failed exchange.
showRouteIdfalseShow the route id.
multilinefalseOne line per part instead of one line in total.
maxChars10000Cut the body after this many characters.
skipBodyLineSeparatortrueReplace line breaks in the body with spaces.
groupSizeLog one throughput line every N messages instead of each message.
groupIntervalLog one throughput line per interval (ms or a duration).
logMaskfalseMask values of sensitive keys such as password or secret.
groupDelay, groupActiveOnly, showCaughtException, showStackTrace, showFiles, showFuture, showStreams, showCachedStreams, showAllProperties, showVariables, plain, style, marker, sourceLocationLoggerName, showRouteGroupAccepted and ignored.

Message headers

The log component reads the message but does not change it.

Run it with Docker

sh
docker run --rm -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/orders.camel.yaml

Log lines go to standard output, so docker logs shows them.

Common questions

How do I log only throughput on a busy route?

Use log:throughput?groupSize=1000 to get one line per 1000 messages with the rate, or groupInterval=10000 for one line every 10 seconds.

How do I hide passwords in the log?

Add logMask=true. Values of keys that look like secrets are replaced with xxxxxx.

What is the difference between to: log:x and - log: "..."?

to: log:x prints a formatted view of the whole exchange. The log step prints the message you write, with Simple expressions such as ${body}.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub